vlc | branch: master | Steve Lhomme <[email protected]> | Wed Apr 3 08:54:04 2019 +0200| [52ad06a43c26f3cebf86616743af6e038401e88a] | committer: Steve Lhomme
modules: use WCHAR when calling wide char Win32 APIs > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=52ad06a43c26f3cebf86616743af6e038401e88a --- modules/codec/dmo/dmo.c | 2 +- modules/control/ntservice.c | 4 +-- modules/gui/eject.c | 4 +-- modules/gui/skins2/win32/win32_factory.cpp | 2 +- modules/services_discovery/windrive.c | 4 +-- modules/text_renderer/freetype/fonts/win32.c | 44 ++++++++++++---------------- modules/video_chroma/d3d11_fmt.c | 20 ++++++------- src/input/es_out_timeshift.c | 4 +-- src/win32/dirs.c | 8 ++--- src/win32/filesystem.c | 4 +-- 10 files changed, 45 insertions(+), 51 deletions(-) diff --git a/modules/codec/dmo/dmo.c b/modules/codec/dmo/dmo.c index 2c6fea8a84..3d00c074aa 100644 --- a/modules/codec/dmo/dmo.c +++ b/modules/codec/dmo/dmo.c @@ -151,7 +151,7 @@ static const GUID guid_wmv9_enc = { 0xd23b90d0, 0x144f, 0x46bd,{ 0x84, 0x1d, 0x5 typedef struct { vlc_fourcc_t i_fourcc; - const TCHAR *psz_dll; + const WCHAR *psz_dll; const GUID *p_guid; } codec_dll; diff --git a/modules/control/ntservice.c b/modules/control/ntservice.c index d61b73ad4f..17c66bb771 100644 --- a/modules/control/ntservice.c +++ b/modules/control/ntservice.c @@ -182,7 +182,7 @@ static int NTServiceInstall( intf_thread_t *p_intf ) intf_sys_t *p_sys = p_intf->p_sys; char *psz_extra; struct vlc_memstream path_stream; - TCHAR psz_pathtmp[MAX_PATH]; + WCHAR psz_pathtmp[MAX_PATH]; SC_HANDLE handle = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS ); if( handle == NULL ) @@ -201,7 +201,7 @@ static int NTServiceInstall( intf_thread_t *p_intf ) /* Find out the filename of ourselves so we can install it to the * service control manager */ GetModuleFileName( NULL, psz_pathtmp, MAX_PATH ); - psz_extra = FromT( psz_pathtmp ); + psz_extra = FromWide( psz_pathtmp ); if ( !psz_extra ) { CloseServiceHandle( handle ); diff --git a/modules/gui/eject.c b/modules/gui/eject.c index c60952ac2d..1f32cafc06 100644 --- a/modules/gui/eject.c +++ b/modules/gui/eject.c @@ -126,12 +126,12 @@ static int intf_Eject( vlc_object_t *p_this, const char *psz_device ) #if defined(_WIN32) MCI_OPEN_PARMS op; DWORD i_flags; - TCHAR psz_drive[4]; + WCHAR psz_drive[4]; memset( &op, 0, sizeof(MCI_OPEN_PARMS) ); op.lpstrDeviceType = (LPCTSTR)MCI_DEVTYPE_CD_AUDIO; - _tcscpy( psz_drive, TEXT("X:") ); + wcscpy( psz_drive, TEXT("X:") ); psz_drive[0] = psz_device[0]; op.lpstrElementName = psz_drive; diff --git a/modules/gui/skins2/win32/win32_factory.cpp b/modules/gui/skins2/win32/win32_factory.cpp index 12be516305..3a470c5472 100644 --- a/modules/gui/skins2/win32/win32_factory.cpp +++ b/modules/gui/skins2/win32/win32_factory.cpp @@ -214,7 +214,7 @@ bool Win32Factory::init() m_trayIcon.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE; m_trayIcon.uCallbackMessage = MY_WM_TRAYACTION; m_trayIcon.hIcon = LoadIcon( m_hInst, vlc_icon ); - _tcscpy( m_trayIcon.szTip, vlc_name ); + wcscpy( m_trayIcon.szTip, vlc_name ); // Show the systray icon if needed if( var_InheritBool( getIntf(), "skins2-systray" ) ) diff --git a/modules/services_discovery/windrive.c b/modules/services_discovery/windrive.c index b0d2b0f83c..5fcde88a50 100644 --- a/modules/services_discovery/windrive.c +++ b/modules/services_discovery/windrive.c @@ -60,12 +60,12 @@ static int Open (vlc_object_t *obj) LONG drives = GetLogicalDrives (); char mrl[12] = "file:///A:/", name[3] = "A:"; - TCHAR path[4] = TEXT("A:\\"); + WCHAR path[4] = TEXT("A:\\"); for (char d = 0; d < 26; d++) { input_item_t *item; - char letter = 'A' + d; + WCHAR letter = 'A' + d; /* Does this drive actually exist? */ if (!(drives & (1 << d))) diff --git a/modules/text_renderer/freetype/fonts/win32.c b/modules/text_renderer/freetype/fonts/win32.c index 4e16ae2454..ae63cf559a 100644 --- a/modules/text_renderer/freetype/fonts/win32.c +++ b/modules/text_renderer/freetype/fonts/win32.c @@ -41,6 +41,7 @@ #include <vlc_common.h> #include <vlc_filter.h> +#include <vlc_charset.h> #include <ft2build.h> #include FT_SFNT_NAMES_H @@ -50,14 +51,13 @@ # include <windows.h> # include <shlobj.h> # include <usp10.h> -# include <vlc_charset.h> /* FromT */ # undef HAVE_FONTCONFIG #endif #include "../platform_fonts.h" #if !VLC_WINSTORE_APP -#define FONT_DIR_NT _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts") +#define FONT_DIR_NT TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts") static inline void AppendFamily( vlc_family_t **pp_list, vlc_family_t *p_family ) { @@ -115,17 +115,17 @@ static int ConcatenatedIndex( char *psz_haystack, const char *psz_needle ) return -1; } -static int GetFileFontByName( LPCTSTR font_name, char **psz_filename, int *i_index ) +static int GetFileFontByName( const WCHAR * font_name, char **psz_filename, int *i_index ) { HKEY hKey; - TCHAR vbuffer[MAX_PATH]; - TCHAR dbuffer[256]; + WCHAR vbuffer[MAX_PATH]; + WCHAR dbuffer[256]; if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, FONT_DIR_NT, 0, KEY_READ, &hKey) != ERROR_SUCCESS ) return 1; - char *font_name_temp = FromT( font_name ); + char *font_name_temp = FromWide( font_name ); for( int index = 0;; index++ ) { @@ -141,7 +141,7 @@ static int GetFileFontByName( LPCTSTR font_name, char **psz_filename, int *i_ind return i_result; } - char *psz_value = FromT( vbuffer ); + char *psz_value = FromWide( vbuffer ); char *s = strchr( psz_value,'(' ); if( s != NULL && s != psz_value ) s[-1] = '\0'; @@ -150,7 +150,7 @@ static int GetFileFontByName( LPCTSTR font_name, char **psz_filename, int *i_ind if( ( i_concat_idx = ConcatenatedIndex( psz_value, font_name_temp ) ) != -1 ) { *i_index = i_concat_idx; - *psz_filename = FromT( dbuffer ); + *psz_filename = FromWide( dbuffer ); free( psz_value ); break; } @@ -169,7 +169,7 @@ static char* GetWindowsFontPath() if( S_OK != SHGetFolderPathW( NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, wdir ) ) { GetWindowsDirectoryW( wdir, MAX_PATH ); - wcscat( wdir, L"\\fonts" ); + wcscat( wdir, TEXT("\\fonts") ); } return FromWide( wdir ); } @@ -260,13 +260,13 @@ static int GetSfntNameString( FT_Byte *p_table, FT_UInt i_size, FT_UShort i_plat * We have to get the English name because that's what the Windows registry uses * for name to file mapping. */ -static TCHAR *GetFullEnglishName( const ENUMLOGFONTEX *lpelfe ) +static WCHAR *GetFullEnglishName( const ENUMLOGFONTEX *lpelfe ) { HFONT hFont = NULL; HDC hDc = NULL; FT_Byte *p_table = NULL; - TCHAR *psz_result = NULL; + WCHAR *psz_result = NULL; hFont = CreateFontIndirect( &lpelfe->elfLogFont ); @@ -318,12 +318,7 @@ static TCHAR *GetFullEnglishName( const ENUMLOGFONTEX *lpelfe ) psz_name[ i ] = U16_AT( p_name + i * 2 ); psz_name[ i_length_in_wchars ] = 0; -#ifdef UNICODE psz_result = psz_name; -#else - psz_result = FromWide( psz_name ); - free( psz_name ); -#endif done: free( p_table ); @@ -358,9 +353,9 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *lpelfe, const NEWTEXTM char *psz_fontfile = NULL; int i_index = 0; - if( GetFileFontByName( (LPCTSTR)lpelfe->elfFullName, &psz_filename, &i_index ) ) + if( GetFileFontByName( lpelfe->elfFullName, &psz_filename, &i_index ) ) { - TCHAR *psz_english_name = GetFullEnglishName( lpelfe ); + WCHAR *psz_english_name = GetFullEnglishName( lpelfe ); if( !psz_english_name ) return 1; @@ -420,8 +415,8 @@ const vlc_family_t *Win32_GetFamily( filter_t *p_filter, const char *psz_family LOGFONT lf; lf.lfCharSet = DEFAULT_CHARSET; - LPTSTR psz_fbuffer = ToT( psz_family ); - _tcsncpy( (LPTSTR)&lf.lfFaceName, psz_fbuffer, LF_FACESIZE ); + LPTSTR psz_fbuffer = ToWide( psz_family ); + wcsncpy( (LPTSTR)&lf.lfFaceName, psz_fbuffer, LF_FACESIZE ); free( psz_fbuffer ); /* */ @@ -459,7 +454,6 @@ static char *UniscribeFallback( const char *psz_family, uni_char_t codepoint ) HDC hdc = NULL; HDC meta_file_dc = NULL; HENHMETAFILE meta_file = NULL; - LPTSTR psz_fbuffer = NULL; char *psz_result = NULL; hdc = CreateCompatibleDC( NULL ); @@ -473,10 +467,10 @@ static char *UniscribeFallback( const char *psz_family, uni_char_t codepoint ) LOGFONT lf; memset( &lf, 0, sizeof( lf ) ); - psz_fbuffer = ToT( psz_family ); + wchar_t *psz_fbuffer = ToWide( psz_family ); if( !psz_fbuffer ) goto error; - _tcsncpy( ( LPTSTR ) &lf.lfFaceName, psz_fbuffer, LF_FACESIZE ); + wcsncpy( ( LPTSTR ) &lf.lfFaceName, psz_fbuffer, LF_FACESIZE ); free( psz_fbuffer ); lf.lfCharSet = DEFAULT_CHARSET; @@ -486,7 +480,7 @@ static char *UniscribeFallback( const char *psz_family, uni_char_t codepoint ) HFONT hOriginalFont = SelectObject( meta_file_dc, hFont ); - TCHAR text = codepoint; + WCHAR text = codepoint; SCRIPT_STRING_ANALYSIS script_analysis; HRESULT hresult = ScriptStringAnalyse( meta_file_dc, &text, 1, 0, -1, @@ -509,7 +503,7 @@ static char *UniscribeFallback( const char *psz_family, uni_char_t codepoint ) log_font.lfFaceName[ 0 ] = 0; EnumEnhMetaFile( 0, meta_file, MetaFileEnumProc, &log_font, NULL ); if( log_font.lfFaceName[ 0 ] ) - psz_result = FromT( log_font.lfFaceName ); + psz_result = FromWide( log_font.lfFaceName ); } DeleteEnhMetaFile(meta_file); diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c index 7512cf9f80..5c2fb8799e 100644 --- a/modules/video_chroma/d3d11_fmt.c +++ b/modules/video_chroma/d3d11_fmt.c @@ -137,15 +137,15 @@ int D3D11_AllocateResourceView(vlc_object_t *obj, ID3D11Device *d3ddevice, static HKEY GetAdapterRegistry(vlc_object_t *obj, DXGI_ADAPTER_DESC *adapterDesc) { HKEY hKey; - TCHAR key[128]; - TCHAR szData[256], lookup[256]; + WCHAR key[128]; + WCHAR szData[256], lookup[256]; DWORD len = 256; LSTATUS ret; - _sntprintf(lookup, 256, TEXT("pci\\ven_%04x&dev_%04x"), adapterDesc->VendorId, adapterDesc->DeviceId); + _snwprintf(lookup, 256, TEXT("pci\\ven_%04x&dev_%04x"), adapterDesc->VendorId, adapterDesc->DeviceId); for (int i=0;;i++) { - _sntprintf(key, 128, TEXT("SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\%04d"), i); + _snwprintf(key, 128, TEXT("SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\%04d"), i); ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey); if ( ret != ERROR_SUCCESS ) { @@ -156,7 +156,7 @@ static HKEY GetAdapterRegistry(vlc_object_t *obj, DXGI_ADAPTER_DESC *adapterDesc len = sizeof(szData); ret = RegQueryValueEx( hKey, TEXT("MatchingDeviceId"), NULL, NULL, (LPBYTE) &szData, &len ); if ( ret == ERROR_SUCCESS ) { - if (_tcsncmp(lookup, szData, _tcslen(lookup)) == 0) + if (wcsncmp(lookup, szData, wcslen(lookup)) == 0) return hKey; msg_Dbg(obj, "different %d device %s vs %s", i, lookup, szData); } @@ -189,8 +189,8 @@ void D3D11_GetDriverVersion(vlc_object_t *obj, d3d11_device_t *d3d_dev) } LONG err = ERROR_ACCESS_DENIED; - TCHAR szData[256]; - DWORD len = 256; + WCHAR szData[256]; + DWORD len = sizeof(szData); HKEY hKey = GetAdapterRegistry(obj, &adapterDesc); if (hKey == NULL) { @@ -209,7 +209,7 @@ void D3D11_GetDriverVersion(vlc_object_t *obj, d3d11_device_t *d3d_dev) int wddm, d3d_features, revision, build; /* see https://docs.microsoft.com/en-us/windows-hardware/drivers/display/wddm-2-1-features#driver-versioning */ - if (_stscanf(szData, TEXT("%d.%d.%d.%d"), &wddm, &d3d_features, &revision, &build) != 4) + if (swscanf(szData, TEXT("%d.%d.%d.%d"), &wddm, &d3d_features, &revision, &build) != 4) { char *driver_version = FromWide(szData); msg_Warn(obj, "the adapter DriverVersion '%s' doesn't match the expected format", driver_version); @@ -701,8 +701,8 @@ static HINSTANCE Direct3D11LoadShaderLibrary(void) HINSTANCE instance = NULL; /* d3dcompiler_47 is the latest on windows 8.1 */ for (int i = 47; i > 41; --i) { - TCHAR filename[19]; - _sntprintf(filename, 19, TEXT("D3DCOMPILER_%d.dll"), i); + WCHAR filename[19]; + _snwprintf(filename, 19, TEXT("D3DCOMPILER_%d.dll"), i); instance = LoadLibrary(filename); if (instance) break; } diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c index ee51662b3f..406c6f2237 100644 --- a/src/input/es_out_timeshift.c +++ b/src/input/es_out_timeshift.c @@ -337,12 +337,12 @@ es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out const DWORD count = GetTempPath( 0, NULL ); if( count > 0 ) { - TCHAR *path = vlc_alloc( count + 1, sizeof(TCHAR) ); + WCHAR *path = vlc_alloc( count + 1, sizeof(WCHAR) ); if( path != NULL ) { DWORD ret = GetTempPath( count + 1, path ); if( ret != 0 && ret <= count ) - p_sys->psz_tmp_path = FromT( path ); + p_sys->psz_tmp_path = FromWide( path ); free( path ); } } diff --git a/src/win32/dirs.c b/src/win32/dirs.c index bfec6411c8..a9c0d68022 100644 --- a/src/win32/dirs.c +++ b/src/win32/dirs.c @@ -258,17 +258,17 @@ static char *config_GetAppDir (void) { #if !VLC_WINSTORE_APP /* if portable directory exists, use it */ - TCHAR path[MAX_PATH]; + WCHAR path[MAX_PATH]; if (GetModuleFileName (NULL, path, MAX_PATH)) { - TCHAR *lastDir = _tcsrchr (path, '\\'); + WCHAR *lastDir = wcsrchr (path, TEXT('\\')); if (lastDir) { - _tcscpy (lastDir + 1, TEXT("portable")); + wcscpy (lastDir + 1, TEXT("portable")); DWORD attrib = GetFileAttributes (path); if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY)) - return FromT (path); + return FromWide (path); } } #endif diff --git a/src/win32/filesystem.c b/src/win32/filesystem.c index ab5ed0b26f..74980c68ef 100644 --- a/src/win32/filesystem.c +++ b/src/win32/filesystem.c @@ -355,12 +355,12 @@ int vlc_accept (int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock) #if !VLC_WINSTORE_APP FILE *vlc_win32_tmpfile(void) { - TCHAR tmp_path[MAX_PATH-14]; + WCHAR tmp_path[MAX_PATH-14]; int i_ret = GetTempPath (MAX_PATH-14, tmp_path); if (i_ret == 0) return NULL; - TCHAR tmp_name[MAX_PATH]; + WCHAR tmp_name[MAX_PATH]; i_ret = GetTempFileName(tmp_path, TEXT("VLC"), 0, tmp_name); if (i_ret == 0) return NULL; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
