Kaydet (Commit) 163dcad7 authored tarafından skswales's avatar skswales Kaydeden (comit) Michael Stahl

Work towards tdf#72606

EasyHack _tstring/TCHAR elimination

These were already compiled UNICODE - changes for clarity and consistency

Change-Id: I846063ddf37af80b3a8787b45d97215e1770c0f3
Reviewed-on: https://gerrit.libreoffice.org/24859Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst c5ab14e2
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#define UNICODE #define UNICODE
#define _UNICODE
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push,1) // disable warnings within system headers #pragma warning(push,1) // disable warnings within system headers
...@@ -31,21 +32,21 @@ ...@@ -31,21 +32,21 @@
#include <string.h> #include <string.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include "strsafe.h" #include <strsafe.h>
#include <seterror.hxx> #include "seterror.hxx"
BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue ) BOOL GetMsiPropW( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
{ {
DWORD sz = 0; DWORD sz = 0;
if ( MsiGetProperty( hMSI, pPropName, const_cast<wchar_t *>(L""), &sz ) == ERROR_MORE_DATA ) if ( MsiGetPropertyW( hMSI, pPropName, const_cast<wchar_t *>(L""), &sz ) == ERROR_MORE_DATA )
{ {
sz++; sz++;
DWORD nbytes = sz * sizeof( wchar_t ); DWORD nbytes = sz * sizeof( wchar_t );
wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) ); wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) );
ZeroMemory( buff, nbytes ); ZeroMemory( buff, nbytes );
MsiGetProperty( hMSI, pPropName, buff, &sz ); MsiGetPropertyW( hMSI, pPropName, buff, &sz );
*ppValue = buff; *ppValue = buff;
return TRUE; return TRUE;
...@@ -56,18 +57,18 @@ BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue ) ...@@ -56,18 +57,18 @@ BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
#ifdef DEBUG #ifdef DEBUG
inline void OutputDebugStringFormat( LPCTSTR pFormat, ... ) inline void OutputDebugStringFormatW( PCWSTR pFormat, ... )
{ {
TCHAR buffer[1024]; WCHAR buffer[1024];
va_list args; va_list args;
va_start( args, pFormat ); va_start( args, pFormat );
StringCchVPrintf( buffer, sizeof(buffer), pFormat, args ); StringCchVPrintfW( buffer, sizeof(buffer)/sizeof(buffer[0]), pFormat, args );
OutputDebugString( buffer ); OutputDebugStringW( buffer );
va_end(args); va_end(args);
} }
#else #else
static inline void OutputDebugStringFormat( LPCTSTR, ... ) static inline void OutputDebugStringFormatW( PCWSTR, ... )
{ {
} }
#endif #endif
...@@ -75,21 +76,21 @@ static inline void OutputDebugStringFormat( LPCTSTR, ... ) ...@@ -75,21 +76,21 @@ static inline void OutputDebugStringFormat( LPCTSTR, ... )
extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI ) extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
{ {
// MessageBox(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION); // MessageBoxW(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION);
wchar_t* pVal = NULL; wchar_t* pVal = NULL;
if ( GetMsiProp( hMSI, L"NEWPRODUCTS", &pVal ) && pVal ) if ( GetMsiPropW( hMSI, L"NEWPRODUCTS", &pVal ) && pVal )
{ {
OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTS found [%s]"), pVal ); OutputDebugStringFormatW( L"DEBUG: NEWPRODUCTS found [%s]", pVal );
if ( *pVal != 0 ) if ( *pVal != 0 )
SetMsiErrorCode( MSI_ERROR_NEW_VERSION_FOUND ); SetMsiErrorCode( MSI_ERROR_NEW_VERSION_FOUND );
free( pVal ); free( pVal );
} }
pVal = NULL; pVal = NULL;
if ( GetMsiProp( hMSI, L"OLDPRODUCTS", &pVal ) && pVal ) if ( GetMsiPropW( hMSI, L"OLDPRODUCTS", &pVal ) && pVal )
{ {
OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTS found [%s]"), pVal ); OutputDebugStringFormatW( L"DEBUG: OLDPRODUCTS found [%s]", pVal );
if ( *pVal != 0 ) if ( *pVal != 0 )
SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND ); SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND );
free( pVal ); free( pVal );
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#define UNICODE #define UNICODE
#define _UNICODE
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push,1) // disable warnings within system headers #pragma warning(push,1) // disable warnings within system headers
...@@ -30,24 +31,24 @@ ...@@ -30,24 +31,24 @@
#include <string.h> #include <string.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include "strsafe.h" #include <strsafe.h>
#include <seterror.hxx> #include "seterror.hxx"
#ifdef DEBUG #ifdef DEBUG
inline void OutputDebugStringFormat( LPCTSTR pFormat, ... ) inline void OutputDebugStringFormatW( PCWSTR pFormat, ... )
{ {
TCHAR buffer[1024]; WCHAR buffer[1024];
va_list args; va_list args;
va_start( args, pFormat ); va_start( args, pFormat );
StringCchVPrintf( buffer, sizeof(buffer), pFormat, args ); StringCchVPrintfW( buffer, sizeof(buffer)/sizeof(buffer[0]), pFormat, args );
OutputDebugString( buffer ); OutputDebugStringW( buffer );
va_end(args); va_end(args);
} }
#else #else
static inline void OutputDebugStringFormat( LPCTSTR, ... ) static inline void OutputDebugStringFormatW( PCWSTR, ... )
{ {
} }
#endif #endif
...@@ -55,19 +56,19 @@ static inline void OutputDebugStringFormat( LPCTSTR, ... ) ...@@ -55,19 +56,19 @@ static inline void OutputDebugStringFormat( LPCTSTR, ... )
void SetMsiErrorCode( int nErrorCode ) void SetMsiErrorCode( int nErrorCode )
{ {
const TCHAR sMemMapName[] = TEXT( "Global\\MsiErrorObject" ); const WCHAR sMemMapName[] = L"Global\\MsiErrorObject";
HANDLE hMapFile; HANDLE hMapFile;
int *pBuf; int *pBuf;
hMapFile = OpenFileMapping( hMapFile = OpenFileMappingW(
FILE_MAP_ALL_ACCESS, // read/write access FILE_MAP_ALL_ACCESS, // read/write access
FALSE, // do not inherit the name FALSE, // do not inherit the name
sMemMapName ); // name of mapping object sMemMapName ); // name of mapping object
if ( hMapFile == NULL ) // can not set error code if ( hMapFile == NULL ) // can not set error code
{ {
OutputDebugStringFormat( TEXT("Could not open map file (%d).\n"), GetLastError() ); OutputDebugStringFormatW( L"Could not open map file (%d).\n", GetLastError() );
return; return;
} }
...@@ -82,7 +83,7 @@ void SetMsiErrorCode( int nErrorCode ) ...@@ -82,7 +83,7 @@ void SetMsiErrorCode( int nErrorCode )
UnmapViewOfFile( pBuf ); UnmapViewOfFile( pBuf );
} }
else else
OutputDebugStringFormat( TEXT("Could not map view of file (%d).\n"), GetLastError() ); OutputDebugStringFormatW( L"Could not map view of file (%d).\n", GetLastError() );
CloseHandle( hMapFile ); CloseHandle( hMapFile );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment