comparison src/loadso/win32/SDL_sysloadso.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
30 #include <windows.h> 30 #include <windows.h>
31 31
32 #include "SDL_loadso.h" 32 #include "SDL_loadso.h"
33 33
34 void * 34 void *
35 SDL_LoadObject (const char *sofile) 35 SDL_LoadObject(const char *sofile)
36 { 36 {
37 void *handle = NULL; 37 void *handle = NULL;
38 const char *loaderror = "Unknown error"; 38 const char *loaderror = "Unknown error";
39 39
40 #if defined(_WIN32_WCE) 40 #if defined(_WIN32_WCE)
41 char errbuf[512]; 41 char errbuf[512];
42 42
43 wchar_t *errbuf_t = SDL_malloc (512 * sizeof (wchar_t)); 43 wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
44 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));
45 45
46 MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, 46 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t,
47 MAX_PATH); 47 MAX_PATH);
48 handle = (void *) LoadLibrary (sofile_t); 48 handle = (void *) LoadLibrary(sofile_t);
49 49
50 /* Generate an error message if all loads failed */ 50 /* Generate an error message if all loads failed */
51 if (handle == NULL) { 51 if (handle == NULL) {
52 FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS | 52 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
53 FORMAT_MESSAGE_FROM_SYSTEM), 53 FORMAT_MESSAGE_FROM_SYSTEM),
54 NULL, GetLastError (), 54 NULL, GetLastError(),
55 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), 55 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
56 errbuf_t, SDL_arraysize (errbuf), NULL); 56 errbuf_t, SDL_arraysize(errbuf), NULL);
57 WideCharToMultiByte (CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, 57 WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
58 NULL);
59 loaderror = errbuf; 58 loaderror = errbuf;
60 } 59 }
61 60
62 SDL_free (sofile_t); 61 SDL_free(sofile_t);
63 SDL_free (errbuf_t); 62 SDL_free(errbuf_t);
64 63
65 #else /*if defined(__WIN32__) */ 64 #else /*if defined(__WIN32__) */
66 char errbuf[512]; 65 char errbuf[512];
67 66
68 handle = (void *) LoadLibrary (sofile); 67 handle = (void *) LoadLibrary(sofile);
69 68
70 /* Generate an error message if all loads failed */ 69 /* Generate an error message if all loads failed */
71 if (handle == NULL) { 70 if (handle == NULL) {
72 FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS | 71 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
73 FORMAT_MESSAGE_FROM_SYSTEM), 72 FORMAT_MESSAGE_FROM_SYSTEM),
74 NULL, GetLastError (), 73 NULL, GetLastError(),
75 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), 74 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
76 errbuf, SDL_arraysize (errbuf), NULL); 75 errbuf, SDL_arraysize(errbuf), NULL);
77 loaderror = errbuf; 76 loaderror = errbuf;
78 } 77 }
79 #endif 78 #endif
80 79
81 if (handle == NULL) { 80 if (handle == NULL) {
82 SDL_SetError ("Failed loading %s: %s", sofile, loaderror); 81 SDL_SetError("Failed loading %s: %s", sofile, loaderror);
83 } 82 }
84 return (handle); 83 return (handle);
85 } 84 }
86 85
87 void * 86 void *
88 SDL_LoadFunction (void *handle, const char *name) 87 SDL_LoadFunction(void *handle, const char *name)
89 { 88 {
90 void *symbol = NULL; 89 void *symbol = NULL;
91 const char *loaderror = "Unknown error"; 90 const char *loaderror = "Unknown error";
92 91
93 #if defined(_WIN32_WCE) 92 #if defined(_WIN32_WCE)
94 char errbuf[512]; 93 char errbuf[512];
95 int length = SDL_strlen (name); 94 int length = SDL_strlen(name);
96 95
97 wchar_t *name_t = SDL_malloc ((length + 1) * sizeof (wchar_t)); 96 wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t));
98 wchar_t *errbuf_t = SDL_malloc (512 * sizeof (wchar_t)); 97 wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
99 98
100 MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length); 99 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length);
101 100
102 symbol = (void *) GetProcAddress ((HMODULE) handle, name_t); 101 symbol = (void *) GetProcAddress((HMODULE) handle, name_t);
103 if (symbol == NULL) { 102 if (symbol == NULL) {
104 FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS | 103 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
105 FORMAT_MESSAGE_FROM_SYSTEM), 104 FORMAT_MESSAGE_FROM_SYSTEM),
106 NULL, GetLastError (), 105 NULL, GetLastError(),
107 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), 106 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
108 errbuf_t, SDL_arraysize (errbuf), NULL); 107 errbuf_t, SDL_arraysize(errbuf), NULL);
109 WideCharToMultiByte (CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, 108 WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
110 NULL);
111 loaderror = errbuf; 109 loaderror = errbuf;
112 } 110 }
113 111
114 SDL_free (name_t); 112 SDL_free(name_t);
115 SDL_free (errbuf_t); 113 SDL_free(errbuf_t);
116 114
117 #else /*if defined(WIN32) */ 115 #else /*if defined(WIN32) */
118 char errbuf[512]; 116 char errbuf[512];
119 117
120 symbol = (void *) GetProcAddress ((HMODULE) handle, name); 118 symbol = (void *) GetProcAddress((HMODULE) handle, name);
121 if (symbol == NULL) { 119 if (symbol == NULL) {
122 FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS | 120 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
123 FORMAT_MESSAGE_FROM_SYSTEM), 121 FORMAT_MESSAGE_FROM_SYSTEM),
124 NULL, GetLastError (), 122 NULL, GetLastError(),
125 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), 123 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
126 errbuf, SDL_arraysize (errbuf), NULL); 124 errbuf, SDL_arraysize(errbuf), NULL);
127 loaderror = errbuf; 125 loaderror = errbuf;
128 } 126 }
129 #endif 127 #endif
130 128
131 if (symbol == NULL) { 129 if (symbol == NULL) {
132 SDL_SetError ("Failed loading %s: %s", name, loaderror); 130 SDL_SetError("Failed loading %s: %s", name, loaderror);
133 } 131 }
134 return (symbol); 132 return (symbol);
135 } 133 }
136 134
137 void 135 void
138 SDL_UnloadObject (void *handle) 136 SDL_UnloadObject(void *handle)
139 { 137 {
140 if (handle != NULL) { 138 if (handle != NULL) {
141 FreeLibrary ((HMODULE) handle); 139 FreeLibrary((HMODULE) handle);
142 } 140 }
143 } 141 }
144 142
145 #endif /* SDL_LOADSO_WIN32 */ 143 #endif /* SDL_LOADSO_WIN32 */
146 /* vi: set ts=4 sw=4 expandtab: */ 144 /* vi: set ts=4 sw=4 expandtab: */