Mercurial > sdl-ios-xcode
annotate src/SDL_loadso.c @ 1135:cf6133247d34
Mac Classic and CodeWarrior patches.
--ryan.
From: =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb@algonet.se>
Subject: Re: [SDL] Updated Mac patch
Date: Tue, 6 Sep 2005 15:21:27 +0200
To: A list for developers using the SDL library <sdl@libsdl.org>
Earlier, I wrote:
> Updated the previous Mac patch to disable Carbon by default.
> Also "fixed" the SDL.spec again, so that it builds on Darwin.
>
> http://www.algonet.se/~afb/SDL-1.2.9-mac.patch
> Also applied fine to SDL12 CVS, when I tried it.
>
> Haven't completed any new packaging or projects for Xcode/PB,
> but it seems to build and install fine here (in development).
Tested the new patch to build with old CodeWarrior and MPW,
and it seems it needed some hacks with those old headers...
Just in case you want to support the archeological versions -
here is a small add-on to the above patch, to fix those...
http://www.algonet.se/~afb/SDL-1.2.9-classic.patch
I couldn't get the old CW5 projects to build without a few
modifications - such as deleting the stray old header in:
"CWprojects/Support/Carbon/Include/ConditionalMacros.h" ?
But I updated both projects to CW6 too and built for Carbon,
and it ran all of the Mac test projects without any problems.
The MPW file seems to have compiled, with a small order change.
As long as you're still shipping the CWProjects and MPWmake
with the download, they should probably be updated/fixed ?
(another "solution" would of course be to just delete them)
I'll post my new projects along with the new Xcode projects
later on, along with XML exports of the various .mcp files.
(CW5 builds for Classic / "PPC", and CW6 builds for Carbon)
It'll be packaged as a part of the next SpriteWorld X release...
http://spriteworldx.sourceforge.net/ [Classic/Carbon/Win/X11]
--anders
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 08 Sep 2005 06:34:28 +0000 |
parents | 0c3e00cc9580 |
children | 51a8702d8ecd |
rev | line source |
---|---|
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
708
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Library General Public License for more details. |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #ifdef SAVE_RCSID |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 static char rcsid = |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 "@(#) $Id$"; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #endif |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 /* System dependent library loading routines */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #include <stdio.h> |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #if defined(USE_DLOPEN) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 # include <dlfcn.h> |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #elif defined(WIN32) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 # include <windows.h> |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 #elif defined(__BEOS__) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 # include <be/kernel/image.h> |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #elif defined(macintosh) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 # include <string.h> |
1135
cf6133247d34
Mac Classic and CodeWarrior patches.
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
40 #define OLDP2C 1 |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 # include <Strings.h> |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 # include <CodeFragments.h> |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 # include <Errors.h> |
651
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
44 #elif defined(__MINT__) && defined(ENABLE_LDG) |
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
45 # include <gem.h> |
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
46 # include <ldg.h> |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 #else |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 /*#error Unsupported dynamic link environment*/ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 #endif /* system type */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
296
fab1ddc4d7bf
Removed the API changes to preserve SDL 1.2 stability
Sam Lantinga <slouken@libsdl.org>
parents:
294
diff
changeset
|
51 #include "SDL_types.h" |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 #include "SDL_error.h" |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 #include "SDL_loadso.h" |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 void *SDL_LoadObject(const char *sofile) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 void *handle = NULL; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 const char *loaderror = "SDL_LoadObject() not implemented"; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 #if defined(USE_DLOPEN) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 /* * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 handle = dlopen(sofile, RTLD_NOW); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 loaderror = (char *)dlerror(); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 #elif defined(WIN32) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 /* * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 char errbuf[512]; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 handle = (void *)LoadLibrary(sofile); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 /* Generate an error message if all loads failed */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 if ( handle == NULL ) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 FORMAT_MESSAGE_FROM_SYSTEM), |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 NULL, GetLastError(), |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 errbuf, SDL_TABLESIZE(errbuf), NULL); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 loaderror = errbuf; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 #elif defined(__BEOS__) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 /* * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 image_id library_id; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 library_id = load_add_on(sofile); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 if ( library_id == B_ERROR ) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 loaderror = "BeOS error"; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 } else { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 handle = (void *)(library_id); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 #elif defined(macintosh) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 /* * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 CFragConnectionID library_id; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 Ptr mainAddr; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 Str255 errName; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 OSErr error; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 char psofile[512]; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 strncpy(psofile, sofile, SDL_TABLESIZE(psofile)); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 psofile[SDL_TABLESIZE(psofile)-1] = '\0'; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch, |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 kLoadCFrag, &library_id, &mainAddr, errName); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 switch (error) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 case noErr: |
774
0c3e00cc9580
Date: Mon, 5 Jan 2004 00:09:36 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
102 loaderror = NULL; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 break; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 case cfragNoLibraryErr: |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 loaderror = "Library not found"; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 break; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 case cfragUnresolvedErr: |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 loaderror = "Unabled to resolve symbols"; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 break; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 case cfragNoPrivateMemErr: |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 case cfragNoClientMemErr: |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 loaderror = "Out of memory"; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 break; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 default: |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 loaderror = "Unknown Code Fragment Manager error"; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 break; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 if ( loaderror == NULL ) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 handle = (void *)(library_id); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 } |
651
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
121 #elif defined(__MINT__) && defined(ENABLE_LDG) |
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
122 /* * */ |
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
123 handle = (void *)ldg_open((char *)sofile, ldg_global); |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 #endif /* system type */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 if ( handle == NULL ) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 SDL_SetError("Failed loading %s: %s", sofile, loaderror); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 return(handle); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 void *SDL_LoadFunction(void *handle, const char *name) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 void *symbol = NULL; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 const char *loaderror = "SDL_LoadFunction not implemented"; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 #if defined(USE_DLOPEN) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 /* * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 symbol = dlsym(handle, name); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 if ( symbol == NULL ) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 loaderror = (char *)dlerror(); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 #elif defined(WIN32) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 /* * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 char errbuf[512]; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 symbol = (void *)GetProcAddress((HMODULE)handle, name); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 if ( symbol == NULL ) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 FORMAT_MESSAGE_FROM_SYSTEM), |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 NULL, GetLastError(), |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 errbuf, SDL_TABLESIZE(errbuf), NULL); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 loaderror = errbuf; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 #elif defined(__BEOS__) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 /* * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 image_id library_id = (image_id)handle; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 if ( get_image_symbol(library_id, |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 name, B_SYMBOL_TYPE_TEXT, &symbol) != B_NO_ERROR ) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 loaderror = "Symbol not found"; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 #elif defined(macintosh) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 /* * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 CFragSymbolClass class; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 CFragConnectionID library_id = (CFragConnectionID)handle; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 char pname[512]; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 strncpy(pname, name, SDL_TABLESIZE(pname)); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 pname[SDL_TABLESIZE(pname)-1] = '\0'; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 if ( FindSymbol(library_id, C2PStr(pname), |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 (char **)&symbol, &class) != noErr ) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 loaderror = "Symbol not found"; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 } |
651
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
174 #elif defined(__MINT__) && defined(ENABLE_LDG) |
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
175 /* * */ |
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
176 symbol = (void *)ldg_find((char *)name, (LDG *)handle); |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 #endif /* system type */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 if ( symbol == NULL ) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 SDL_SetError("Failed loading %s: %s", name, loaderror); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 return(symbol); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 void SDL_UnloadObject(void *handle) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 { |
336
745873ea091f
BeOS compile fix for shared object loading code
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
187 #if defined(__BEOS__) |
745873ea091f
BeOS compile fix for shared object loading code
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
188 image_id library_id; |
707
c67d4fb10a45
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
651
diff
changeset
|
189 #elif defined(macintosh) |
c67d4fb10a45
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
651
diff
changeset
|
190 CFragConnectionID library_id; |
336
745873ea091f
BeOS compile fix for shared object loading code
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
191 #endif |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 if ( handle == NULL ) { |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 return; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 #if defined(USE_DLOPEN) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 /* * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 dlclose(handle); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 #elif defined(WIN32) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 /* * */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 FreeLibrary((HMODULE)handle); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 #elif defined(__BEOS__) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 /* * */ |
336
745873ea091f
BeOS compile fix for shared object loading code
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
203 library_id = (image_id)handle; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 unload_add_on(library_id); |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 #elif defined(macintosh) |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 /* * */ |
707
c67d4fb10a45
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
651
diff
changeset
|
207 library_id = (CFragConnectionID)handle; |
708
d0d50f2b044c
Fixed building SDL_loadso.c on MacOS Classic
Sam Lantinga <slouken@libsdl.org>
parents:
707
diff
changeset
|
208 CloseConnection(&library_id); |
651
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
209 #elif defined(__MINT__) && defined(ENABLE_LDG) |
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
210 /* * */ |
35ff0890ac4e
pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents:
336
diff
changeset
|
211 ldg_close((LDG *)handle, ldg_global); |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 #endif /* system type */ |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 } |