src/SDL_loadso.c
changeset 1152 51a8702d8ecd
parent 1135 cf6133247d34
child 1173 e9cf8c1b4590
     1.1 --- a/src/SDL_loadso.c	Wed Sep 28 11:36:20 2005 +0000
     1.2 +++ b/src/SDL_loadso.c	Thu Sep 29 09:43:00 2005 +0000
     1.3 @@ -31,7 +31,7 @@
     1.4  #include <stdio.h>
     1.5  #if defined(USE_DLOPEN)
     1.6  # include <dlfcn.h>
     1.7 -#elif defined(WIN32)
     1.8 +#elif defined(WIN32) || defined(_WIN32_WCE)
     1.9  # include <windows.h>
    1.10  #elif defined(__BEOS__)
    1.11  # include <be/kernel/image.h>
    1.12 @@ -60,6 +60,30 @@
    1.13  /* * */
    1.14  	handle = dlopen(sofile, RTLD_NOW);
    1.15  	loaderror = (char *)dlerror();
    1.16 +#elif defined(_WIN32_WCE)
    1.17 +/* * */
    1.18 +	char errbuf[512];
    1.19 +
    1.20 +	wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t));
    1.21 +	wchar_t *sofile_t = malloc((MAX_PATH+1) * sizeof(wchar_t));
    1.22 +
    1.23 +	MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, MAX_PATH);
    1.24 +	handle = (void *)LoadLibrary(sofile_t);
    1.25 +
    1.26 +	/* Generate an error message if all loads failed */
    1.27 +	if ( handle == NULL ) {
    1.28 +		FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
    1.29 +					FORMAT_MESSAGE_FROM_SYSTEM),
    1.30 +				NULL, GetLastError(), 
    1.31 +				MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    1.32 +				errbuf_t, SDL_TABLESIZE(errbuf), NULL);
    1.33 +		WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
    1.34 +		loaderror = errbuf;
    1.35 +	}
    1.36 +
    1.37 +	free(sofile_t);
    1.38 +	free(errbuf_t);
    1.39 +
    1.40  #elif defined(WIN32)
    1.41  /* * */
    1.42  	char errbuf[512];
    1.43 @@ -139,6 +163,30 @@
    1.44  	if ( symbol == NULL ) {
    1.45  		loaderror = (char *)dlerror();
    1.46  	}
    1.47 +#elif defined(_WIN32_WCE)
    1.48 +/* * */
    1.49 +	char errbuf[512];
    1.50 +	int length = strlen(name);
    1.51 +
    1.52 +	wchar_t *name_t = malloc((length + 1) * sizeof(wchar_t));
    1.53 +	wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t));
    1.54 +
    1.55 +	MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length);
    1.56 +
    1.57 +	symbol = (void *)GetProcAddress((HMODULE)handle, name_t);
    1.58 +	if ( symbol == NULL ) {
    1.59 +		FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
    1.60 +					FORMAT_MESSAGE_FROM_SYSTEM),
    1.61 +				NULL, GetLastError(), 
    1.62 +				MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    1.63 +				errbuf_t, SDL_TABLESIZE(errbuf), NULL);
    1.64 +		WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
    1.65 +		loaderror = errbuf;
    1.66 +	}
    1.67 +
    1.68 +	free(name_t);
    1.69 +	free(errbuf_t);
    1.70 +
    1.71  #elif defined(WIN32)
    1.72  /* * */
    1.73  	char errbuf[512];