From: Thorsten Engel Date: Tue, 10 May 2005 09:15:38 +0000 (+0000) Subject: -- load cwprintf and cgetws dynamically via winapi X-Git-Tag: Release-1.38.0~479 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=35d5d15f383308848775c5cb366bde1577ae39ba;p=bacula%2Fbacula -- load cwprintf and cgetws dynamically via winapi git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2019 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/lib/winapi.c b/bacula/src/lib/winapi.c index 3c1d16390d..9a5f6532cf 100644 --- a/bacula/src/lib/winapi.c +++ b/bacula/src/lib/winapi.c @@ -49,6 +49,10 @@ t_CreateFileW p_CreateFileW = NULL; t_wunlink p_wunlink = NULL; t_wmkdir p_wmkdir = NULL; t_wopen p_wopen = NULL; + +t_cgetws p_cgetws = NULL; +t_cwprintf p_cwprintf = NULL; + t_GetFileAttributesA p_GetFileAttributesA = NULL; t_GetFileAttributesW p_GetFileAttributesW = NULL; @@ -145,7 +149,14 @@ InitWinAPIWrapper() /* wopen */ p_wopen = (t_wopen) GetProcAddress(hLib, "_wopen"); - + + /* cgetws */ + p_cgetws = (t_cgetws) + GetProcAddress (hLib, "_cgetws"); + /* cwprintf */ + p_cwprintf = (t_cwprintf) + GetProcAddress (hLib, "_cwprintf"); + FreeLibrary(hLib); } diff --git a/bacula/src/lib/winapi.h b/bacula/src/lib/winapi.h index 2e8216d769..b57dbb6802 100644 --- a/bacula/src/lib/winapi.h +++ b/bacula/src/lib/winapi.h @@ -66,9 +66,15 @@ typedef int (__cdecl * t_wunlink) (const wchar_t *); typedef int (__cdecl * t_wmkdir) (const wchar_t *); typedef int (__cdecl * t_wopen) (const wchar_t *, int, ...); +typedef wchar_t* (__cdecl *t_cgetws) (wchar_t *); +typedef int (__cdecl *t_cwprintf) (const wchar_t *, ...); + extern t_wunlink p_wunlink; extern t_wmkdir p_wmkdir; extern t_wopen p_wopen; + +extern t_cgetws p_cgetws; +extern t_cwprintf p_cwprintf; /* In KERNEL32.DLL */ typedef BOOL (WINAPI * t_GetFileAttributesExA)(LPCSTR, GET_FILEEX_INFO_LEVELS, LPVOID); @@ -135,6 +141,11 @@ extern t_SetCurrentDirectoryW p_SetCurrentDirectoryW; extern t_GetCurrentDirectoryA p_GetCurrentDirectoryA; extern t_GetCurrentDirectoryW p_GetCurrentDirectoryW; +#ifdef WIN32_VSS +class VSSClient; +extern VSSClient g_VSSClient; +#endif + void InitWinAPIWrapper(); #endif diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index 7d6d1c4c17..481ff2e375 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -935,10 +935,10 @@ win32_fputs(const char *string, FILE *stream) this works under nt and 98 (95 and me not tested) */ - if (p_MultiByteToWideChar && (stream == stdout)) { + if (p_MultiByteToWideChar && (stream == stdout) && p_cwprintf) { WCHAR szBuf[MAX_PATH_UNICODE]; UTF8_2_wchar(szBuf, string, MAX_PATH_UNICODE); - return _cwprintf (szBuf); + return p_cwprintf (szBuf); } return fputs(string, stream); @@ -951,10 +951,10 @@ win32_cgets (char* buffer, int len) from the win32 console */ /* nt and unicode conversion */ - if ((g_platform_id == VER_PLATFORM_WIN32_NT) && p_WideCharToMultiByte) { + if ((g_platform_id == VER_PLATFORM_WIN32_NT) && p_WideCharToMultiByte && p_cgetws) { WCHAR szBuf[260]; szBuf[0] = min (255, len); /* max len, must be smaller than buffer */ - if (!_cgetws (szBuf)) + if (!p_cgetws (szBuf)) return NULL; if (wchar_2_UTF8(buffer, &szBuf[2], len))