comparison src/loadso/win32/SDL_sysloadso.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents 92947e3a18db
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
29 #define WIN32_LEAN_AND_MEAN 29 #define WIN32_LEAN_AND_MEAN
30 #include <windows.h> 30 #include <windows.h>
31 31
32 #include "SDL_loadso.h" 32 #include "SDL_loadso.h"
33 33
34 void *SDL_LoadObject(const char *sofile) 34 void *
35 SDL_LoadObject (const char *sofile)
35 { 36 {
36 void *handle = NULL; 37 void *handle = NULL;
37 const char *loaderror = "Unknown error"; 38 const char *loaderror = "Unknown error";
38 39
39 #if defined(_WIN32_WCE) 40 #if defined(_WIN32_WCE)
40 char errbuf[512]; 41 char errbuf[512];
41 42
42 wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t)); 43 wchar_t *errbuf_t = SDL_malloc (512 * sizeof (wchar_t));
43 wchar_t *sofile_t = SDL_malloc((MAX_PATH+1) * sizeof(wchar_t)); 44 wchar_t *sofile_t = SDL_malloc ((MAX_PATH + 1) * sizeof (wchar_t));
44 45
45 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, MAX_PATH); 46 MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t,
46 handle = (void *)LoadLibrary(sofile_t); 47 MAX_PATH);
48 handle = (void *) LoadLibrary (sofile_t);
47 49
48 /* Generate an error message if all loads failed */ 50 /* Generate an error message if all loads failed */
49 if ( handle == NULL ) { 51 if (handle == NULL) {
50 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | 52 FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS |
51 FORMAT_MESSAGE_FROM_SYSTEM), 53 FORMAT_MESSAGE_FROM_SYSTEM),
52 NULL, GetLastError(), 54 NULL, GetLastError (),
53 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 55 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
54 errbuf_t, SDL_arraysize(errbuf), NULL); 56 errbuf_t, SDL_arraysize (errbuf), NULL);
55 WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); 57 WideCharToMultiByte (CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL,
56 loaderror = errbuf; 58 NULL);
57 } 59 loaderror = errbuf;
60 }
58 61
59 SDL_free(sofile_t); 62 SDL_free (sofile_t);
60 SDL_free(errbuf_t); 63 SDL_free (errbuf_t);
61 64
62 #else /*if defined(__WIN32__)*/ 65 #else /*if defined(__WIN32__) */
63 char errbuf[512]; 66 char errbuf[512];
64 67
65 handle = (void *)LoadLibrary(sofile); 68 handle = (void *) LoadLibrary (sofile);
66 69
67 /* Generate an error message if all loads failed */ 70 /* Generate an error message if all loads failed */
68 if ( handle == NULL ) { 71 if (handle == NULL) {
69 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | 72 FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS |
70 FORMAT_MESSAGE_FROM_SYSTEM), 73 FORMAT_MESSAGE_FROM_SYSTEM),
71 NULL, GetLastError(), 74 NULL, GetLastError (),
72 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 75 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
73 errbuf, SDL_arraysize(errbuf), NULL); 76 errbuf, SDL_arraysize (errbuf), NULL);
74 loaderror = errbuf; 77 loaderror = errbuf;
75 } 78 }
76 #endif 79 #endif
77 80
78 if ( handle == NULL ) { 81 if (handle == NULL) {
79 SDL_SetError("Failed loading %s: %s", sofile, loaderror); 82 SDL_SetError ("Failed loading %s: %s", sofile, loaderror);
80 } 83 }
81 return(handle); 84 return (handle);
82 } 85 }
83 86
84 void *SDL_LoadFunction(void *handle, const char *name) 87 void *
88 SDL_LoadFunction (void *handle, const char *name)
85 { 89 {
86 void *symbol = NULL; 90 void *symbol = NULL;
87 const char *loaderror = "Unknown error"; 91 const char *loaderror = "Unknown error";
88 92
89 #if defined(_WIN32_WCE) 93 #if defined(_WIN32_WCE)
90 char errbuf[512]; 94 char errbuf[512];
91 int length = SDL_strlen(name); 95 int length = SDL_strlen (name);
92 96
93 wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t)); 97 wchar_t *name_t = SDL_malloc ((length + 1) * sizeof (wchar_t));
94 wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t)); 98 wchar_t *errbuf_t = SDL_malloc (512 * sizeof (wchar_t));
95 99
96 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length); 100 MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length);
97 101
98 symbol = (void *)GetProcAddress((HMODULE)handle, name_t); 102 symbol = (void *) GetProcAddress ((HMODULE) handle, name_t);
99 if ( symbol == NULL ) { 103 if (symbol == NULL) {
100 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | 104 FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS |
101 FORMAT_MESSAGE_FROM_SYSTEM), 105 FORMAT_MESSAGE_FROM_SYSTEM),
102 NULL, GetLastError(), 106 NULL, GetLastError (),
103 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 107 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
104 errbuf_t, SDL_arraysize(errbuf), NULL); 108 errbuf_t, SDL_arraysize (errbuf), NULL);
105 WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); 109 WideCharToMultiByte (CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL,
106 loaderror = errbuf; 110 NULL);
107 } 111 loaderror = errbuf;
112 }
108 113
109 SDL_free(name_t); 114 SDL_free (name_t);
110 SDL_free(errbuf_t); 115 SDL_free (errbuf_t);
111 116
112 #else /*if defined(WIN32)*/ 117 #else /*if defined(WIN32) */
113 char errbuf[512]; 118 char errbuf[512];
114 119
115 symbol = (void *)GetProcAddress((HMODULE)handle, name); 120 symbol = (void *) GetProcAddress ((HMODULE) handle, name);
116 if ( symbol == NULL ) { 121 if (symbol == NULL) {
117 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | 122 FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS |
118 FORMAT_MESSAGE_FROM_SYSTEM), 123 FORMAT_MESSAGE_FROM_SYSTEM),
119 NULL, GetLastError(), 124 NULL, GetLastError (),
120 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 125 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
121 errbuf, SDL_arraysize(errbuf), NULL); 126 errbuf, SDL_arraysize (errbuf), NULL);
122 loaderror = errbuf; 127 loaderror = errbuf;
123 } 128 }
124 #endif 129 #endif
125 130
126 if ( symbol == NULL ) { 131 if (symbol == NULL) {
127 SDL_SetError("Failed loading %s: %s", name, loaderror); 132 SDL_SetError ("Failed loading %s: %s", name, loaderror);
128 } 133 }
129 return(symbol); 134 return (symbol);
130 } 135 }
131 136
132 void SDL_UnloadObject(void *handle) 137 void
138 SDL_UnloadObject (void *handle)
133 { 139 {
134 if ( handle != NULL ) { 140 if (handle != NULL) {
135 FreeLibrary((HMODULE)handle); 141 FreeLibrary ((HMODULE) handle);
136 } 142 }
137 } 143 }
138 144
139 #endif /* SDL_LOADSO_WIN32 */ 145 #endif /* SDL_LOADSO_WIN32 */
146 /* vi: set ts=4 sw=4 expandtab: */