Mercurial > sdl-ios-xcode
diff src/SDL_loadso.c @ 1152:51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
activekitten.com.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 29 Sep 2005 09:43:00 +0000 |
parents | cf6133247d34 |
children | e9cf8c1b4590 |
line wrap: on
line diff
--- a/src/SDL_loadso.c Wed Sep 28 11:36:20 2005 +0000 +++ b/src/SDL_loadso.c Thu Sep 29 09:43:00 2005 +0000 @@ -31,7 +31,7 @@ #include <stdio.h> #if defined(USE_DLOPEN) # include <dlfcn.h> -#elif defined(WIN32) +#elif defined(WIN32) || defined(_WIN32_WCE) # include <windows.h> #elif defined(__BEOS__) # include <be/kernel/image.h> @@ -60,6 +60,30 @@ /* * */ handle = dlopen(sofile, RTLD_NOW); loaderror = (char *)dlerror(); +#elif defined(_WIN32_WCE) +/* * */ + char errbuf[512]; + + wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t)); + wchar_t *sofile_t = malloc((MAX_PATH+1) * sizeof(wchar_t)); + + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, MAX_PATH); + handle = (void *)LoadLibrary(sofile_t); + + /* Generate an error message if all loads failed */ + if ( handle == NULL ) { + FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM), + NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + errbuf_t, SDL_TABLESIZE(errbuf), NULL); + WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); + loaderror = errbuf; + } + + free(sofile_t); + free(errbuf_t); + #elif defined(WIN32) /* * */ char errbuf[512]; @@ -139,6 +163,30 @@ if ( symbol == NULL ) { loaderror = (char *)dlerror(); } +#elif defined(_WIN32_WCE) +/* * */ + char errbuf[512]; + int length = strlen(name); + + wchar_t *name_t = malloc((length + 1) * sizeof(wchar_t)); + wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t)); + + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length); + + symbol = (void *)GetProcAddress((HMODULE)handle, name_t); + if ( symbol == NULL ) { + FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM), + NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + errbuf_t, SDL_TABLESIZE(errbuf), NULL); + WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); + loaderror = errbuf; + } + + free(name_t); + free(errbuf_t); + #elif defined(WIN32) /* * */ char errbuf[512];