diff options
author | Andrey Nazarov <skuller@skuller.net> | 2008-11-13 18:58:41 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2008-11-13 18:58:41 +0000 |
commit | bbefa87db18f5b76dc67efa00b7cc798361480f3 (patch) | |
tree | efc130fe3b4fe22f111154a8720491b756daa7bd /source/win_ascii.c | |
parent | d65e02496cd9873f5bb0297661b19762b44ddfec (diff) |
Hacked the source to get it compile on Windows Mobile using CeGCC toolchain.
Fixed nasty memory corruption bug in UI scripts loading code.
Fixed software refresh compilation issues on Windows.
Inactive MVD channels are now completely destroyed and recreated once
they are active again, and they are no longer allowed to stay in waiting
state forever.
Fixed delay buffer overflow resulting in fatal connection error.
Preserve MVD stream flags in demos recorded on GTV server,
and handle `inuse' flag correctly on players when writing gamestate.
Updated documentation and Debian package descriptions.
Diffstat (limited to 'source/win_ascii.c')
-rw-r--r-- | source/win_ascii.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/source/win_ascii.c b/source/win_ascii.c new file mode 100644 index 0000000..d23dcd4 --- /dev/null +++ b/source/win_ascii.c @@ -0,0 +1,95 @@ +#include <windows.h> + +HANDLE WINAPI FindFirstFileA( LPCSTR path, LPWIN32_FIND_DATAA data ) { + WCHAR wbuffer[MAX_PATH]; + HANDLE ret; + WIN32_FIND_DATAW wdata; + + if( !MultiByteToWideChar( CP_ACP, 0, path, -1, wbuffer, MAX_PATH ) ) { + return INVALID_HANDLE_VALUE; + } + + ret = FindFirstFileW( wbuffer, &wdata ); + if( ret != INVALID_HANDLE_VALUE ) { + memcpy( data, &wdata, FIELD_OFFSET( WIN32_FIND_DATAA, cFileName ) ); + WideCharToMultiByte( CP_ACP, 0, wdata.cFileName, -1, data->cFileName, MAX_PATH, NULL, NULL ); + } + + return ret; +} + +BOOL WINAPI FindNextFileA( HANDLE handle, LPWIN32_FIND_DATAA data ) { + BOOL ret; + WIN32_FIND_DATAW wdata; + + ret = FindNextFileW( handle, &wdata ); + if( ret != FALSE ) { + memcpy( data, &wdata, FIELD_OFFSET( WIN32_FIND_DATAA, cFileName ) ); + WideCharToMultiByte( CP_ACP, 0, wdata.cFileName, -1, data->cFileName, MAX_PATH, NULL, NULL ); + } + + return ret; +} + +HINSTANCE WINAPI LoadLibraryA( LPCSTR path ) { + WCHAR wbuffer[MAX_PATH]; + + if( !MultiByteToWideChar( CP_ACP, 0, path, -1, wbuffer, MAX_PATH ) ) { + return NULL; + } + + return LoadLibraryW( wbuffer ); +} + +int WINAPI MessageBoxA( HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType ) { + WCHAR wText[4096]; + WCHAR wCaption[256]; + + if( !MultiByteToWideChar( CP_ACP, 0, lpText, -1, wText, 4096 ) ) { + return 0; + } + if( !MultiByteToWideChar( CP_ACP, 0, lpCaption, -1, wCaption, 256 ) ) { + return 0; + } + + return MessageBoxW( hWnd, wText, wCaption, uType ); +} + +BOOL WINAPI CreateDirectoryA( LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes ) { + WCHAR wbuffer[MAX_PATH]; + + if( !MultiByteToWideChar( CP_ACP, 0, lpPathName, -1, wbuffer, MAX_PATH ) ) { + return FALSE; + } + + return CreateDirectoryW( wbuffer, lpSecurityAttributes ); +} + +BOOL WINAPI GetFileAttributesExA( LPCSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation ) { + WCHAR wbuffer[MAX_PATH]; + + if( !MultiByteToWideChar( CP_ACP, 0, lpFileName, -1, wbuffer, MAX_PATH ) ) { + return FALSE; + } + + return GetFileAttributesExW( wbuffer, fInfoLevelId, lpFileInformation ); +} + +DWORD WINAPI GetModuleFileNameA( HMODULE hModule, LPSTR lpFileName, DWORD nSize ) { + WCHAR wbuffer[MAX_PATH]; + DWORD ret; + + if( nSize > MAX_PATH ) { + nSize = MAX_PATH; + } + + ret = GetModuleFileNameW( hModule, wbuffer, nSize ); + if( ret ) { + if( !WideCharToMultiByte( CP_ACP, 0, wbuffer, ret, lpFileName, ret, NULL, NULL ) ) { + return 0; + } + } + + return ret; +} + |