Mercurial > sdl-ios-xcode
annotate src/loadso/windows/SDL_loadso.c @ 1336:3692456e7b0f
Use SDL_ prefixed versions of C library functions.
FIXME:
Change #include <stdlib.h> to #include "SDL_stdlib.h"
Change #include <string.h> to #include "SDL_string.h"
Make sure nothing else broke because of this...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 06:59:48 +0000 |
parents | 450721ad5436 |
children | c71e05b4dc2e |
rev | line source |
---|---|
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 /* |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
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:
1173
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
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:
1173
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
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:
1173
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
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:
1173
diff
changeset
|
13 Lesser General Public License for more details. |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1173
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:
1173
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:
1173
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 Sam Lantinga |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 */ |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 /* System dependent library loading routines */ |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 #if !SDL_INTERNAL_BUILDING_LOADSO |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 #error Do not compile directly...compile src/SDL_loadso.c instead! |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 #endif |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 #if !defined(WIN32) && !defined(_WIN32_WCE) |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 #error Compiling for the wrong platform? |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 #endif |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
34 #include "SDL_windows.h" |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 #include "SDL_types.h" |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 #include "SDL_error.h" |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 #include "SDL_loadso.h" |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 void *SDL_LoadObject(const char *sofile) |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 { |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 void *handle = NULL; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
43 const char *loaderror = "Unknown error"; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
44 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
45 #if defined(_WIN32_WCE) |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 char errbuf[512]; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
48 wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t)); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
49 wchar_t *sofile_t = SDL_malloc((MAX_PATH+1) * sizeof(wchar_t)); |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, MAX_PATH); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 handle = (void *)LoadLibrary(sofile_t); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
53 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
54 /* Generate an error message if all loads failed */ |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
55 if ( handle == NULL ) { |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
57 FORMAT_MESSAGE_FROM_SYSTEM), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
58 NULL, GetLastError(), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
60 errbuf_t, SDL_TABLESIZE(errbuf), NULL); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 loaderror = errbuf; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 } |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
65 SDL_free(sofile_t); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
66 SDL_free(errbuf_t); |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 #else /*if defined(WIN32)*/ |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 char errbuf[512]; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 handle = (void *)LoadLibrary(sofile); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
73 /* Generate an error message if all loads failed */ |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
74 if ( handle == NULL ) { |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
75 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
76 FORMAT_MESSAGE_FROM_SYSTEM), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
77 NULL, GetLastError(), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
78 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
79 errbuf, SDL_TABLESIZE(errbuf), NULL); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
80 loaderror = errbuf; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
81 } |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
82 #endif |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
83 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
84 if ( handle == NULL ) { |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
85 SDL_SetError("Failed loading %s: %s", sofile, loaderror); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
86 } |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
87 return(handle); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
88 } |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
89 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
90 void *SDL_LoadFunction(void *handle, const char *name) |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
91 { |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
92 void *symbol = NULL; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
93 const char *loaderror = "Unknown error"; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
94 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
95 #if defined(_WIN32_WCE) |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
96 char errbuf[512]; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
97 int length = SDL_strlen(name); |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
98 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
99 wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t)); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
100 wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t)); |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
101 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
102 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
103 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
104 symbol = (void *)GetProcAddress((HMODULE)handle, name_t); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
105 if ( symbol == NULL ) { |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
106 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
107 FORMAT_MESSAGE_FROM_SYSTEM), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
108 NULL, GetLastError(), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
109 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
110 errbuf_t, SDL_TABLESIZE(errbuf), NULL); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
111 WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
112 loaderror = errbuf; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
113 } |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
114 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
115 SDL_free(name_t); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
116 SDL_free(errbuf_t); |
1173
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
117 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
118 #else /*if defined(WIN32)*/ |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
119 char errbuf[512]; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
120 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
121 symbol = (void *)GetProcAddress((HMODULE)handle, name); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
122 if ( symbol == NULL ) { |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
123 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
124 FORMAT_MESSAGE_FROM_SYSTEM), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
125 NULL, GetLastError(), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
126 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
127 errbuf, SDL_TABLESIZE(errbuf), NULL); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
128 loaderror = errbuf; |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
129 } |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
130 #endif |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
131 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 if ( symbol == NULL ) { |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
133 SDL_SetError("Failed loading %s: %s", name, loaderror); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
134 } |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 return(symbol); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
136 } |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 void SDL_UnloadObject(void *handle) |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
139 { |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
140 if ( handle != NULL ) { |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 FreeLibrary((HMODULE)handle); |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
142 } |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
143 } |
e9cf8c1b4590
Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
144 |