zenilib: zenilib/jni/external/sdl/src/loadso/windows/SDL_sysloadso.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_sysloadso.c
Go to the documentation of this file.
1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "SDL_config.h"
22
23 #ifdef SDL_LOADSO_WINDOWS
24
25 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26 /* System dependent library loading routines */
27
28 #include "../../core/windows/SDL_windows.h"
29
30 #include "SDL_loadso.h"
31
32 void *
33 SDL_LoadObject(const char *sofile)
34 {
35 LPTSTR tstr = WIN_UTF8ToString(sofile);
36 void *handle = (void *) LoadLibrary(tstr);
37 SDL_free(tstr);
38
39 /* Generate an error message if all loads failed */
40 if (handle == NULL) {
41 char errbuf[512];
42 SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf));
43 SDL_strlcat(errbuf, sofile, SDL_arraysize(errbuf));
44 WIN_SetError(errbuf);
45 }
46 return handle;
47 }
48
49 void *
50 SDL_LoadFunction(void *handle, const char *name)
51 {
52 void *symbol = (void *) GetProcAddress((HMODULE) handle, name);
53 if (symbol == NULL) {
54 char errbuf[512];
55 SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf));
56 SDL_strlcat(errbuf, name, SDL_arraysize(errbuf));
57 WIN_SetError(errbuf);
58 }
59 return symbol;
60 }
61
62 void
63 SDL_UnloadObject(void *handle)
64 {
65 if (handle != NULL) {
66 FreeLibrary((HMODULE) handle);
67 }
68 }
69
70 #endif /* SDL_LOADSO_WINDOWS */
71
72 /* vi: set ts=4 sw=4 expandtab: */
WIN_UTF8ToString
#define WIN_UTF8ToString(S)
Definition: SDL_windows.h:42
NULL
#define NULL
Definition: ftobjs.h:61
SDL_free
DECLSPEC void SDLCALL SDL_free(void *mem)
name
EGLImageKHR EGLint * name
Definition: eglext.h:284
SDL_strlcat
DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:496
SDL_config.h
SDL_LoadObject
DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile)
SDL_strlcpy
DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:448
SDL_UnloadObject
DECLSPEC void SDLCALL SDL_UnloadObject(void *handle)
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:83
WIN_SetError
int WIN_SetError(const char *prefix)
SDL_loadso.h
handle
EGLImageKHR EGLint EGLint * handle
Definition: eglext.h:284
SDL_LoadFunction
DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, const char *name)