Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
79 lines (65 loc) · 2.31 KB

SDL_sysloadso.c

File metadata and controls

79 lines (65 loc) · 2.31 KB
 
Apr 8, 2011
Apr 8, 2011
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Feb 21, 2006
Feb 21, 2006
21
#include "SDL_config.h"
Jan 21, 2011
Jan 21, 2011
23
#ifdef SDL_LOADSO_WINDOWS
Apr 14, 2006
Apr 14, 2006
24
25
26
27
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent library loading routines */
Jan 25, 2011
Jan 25, 2011
28
#include "../../core/windows/SDL_windows.h"
29
30
31
#include "SDL_loadso.h"
Jul 10, 2006
Jul 10, 2006
32
33
void *
SDL_LoadObject(const char *sofile)
Jan 25, 2011
Jan 25, 2011
35
36
37
LPTSTR tstr = WIN_UTF8ToString(sofile);
void *handle = (void *) LoadLibrary(tstr);
SDL_free(tstr);
Jul 10, 2006
Jul 10, 2006
38
39
40
/* Generate an error message if all loads failed */
if (handle == NULL) {
Jan 25, 2011
Jan 25, 2011
41
42
43
44
char errbuf[512];
SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf));
SDL_strlcat(errbuf, sofile, SDL_arraysize(errbuf));
WIN_SetError(errbuf);
Jul 10, 2006
Jul 10, 2006
45
}
Jan 25, 2011
Jan 25, 2011
46
return handle;
Jul 10, 2006
Jul 10, 2006
49
50
void *
SDL_LoadFunction(void *handle, const char *name)
Jan 25, 2011
Jan 25, 2011
52
53
54
55
56
57
#ifdef _WIN32_WCE
LPTSTR tstr = WIN_UTF8ToString(name);
void *symbol = (void *) GetProcAddress((HMODULE) handle, tstr);
SDL_free(tstr);
#else
void *symbol = (void *) GetProcAddress((HMODULE) handle, name);
58
59
#endif
Jul 10, 2006
Jul 10, 2006
60
if (symbol == NULL) {
Jan 25, 2011
Jan 25, 2011
61
62
63
64
char errbuf[512];
SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf));
SDL_strlcat(errbuf, name, SDL_arraysize(errbuf));
WIN_SetError(errbuf);
Jul 10, 2006
Jul 10, 2006
65
}
Jan 25, 2011
Jan 25, 2011
66
return symbol;
Jul 10, 2006
Jul 10, 2006
69
70
void
SDL_UnloadObject(void *handle)
Jul 10, 2006
Jul 10, 2006
72
73
74
if (handle != NULL) {
FreeLibrary((HMODULE) handle);
}
Jan 21, 2011
Jan 21, 2011
77
#endif /* SDL_LOADSO_WINDOWS */
Oct 18, 2008
Oct 18, 2008
78
Jul 10, 2006
Jul 10, 2006
79
/* vi: set ts=4 sw=4 expandtab: */