summaryrefslogtreecommitdiff
path: root/sal/qa/osl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-09-26 22:05:15 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-09-27 06:27:59 +0200
commit48db718042d32bffe95ec058d636ed935d98ec4d (patch)
treed7d8ca38723fbdf1f20992ea25dc229fb3e785b2 /sal/qa/osl
parentd32506e9f4ea604532bf5f4ba8a302b652aeaaa1 (diff)
SAL: use more Unicode on Windows
Change-Id: I9f54c8e8c4e617cc1ed6b436ca8c162d381ecab3 Reviewed-on: https://gerrit.libreoffice.org/42828 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal/qa/osl')
-rw-r--r--sal/qa/osl/security/osl_Security.cxx54
1 files changed, 28 insertions, 26 deletions
diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index c1268b256bc6..90502118cfed 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -360,38 +360,40 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
/// some initialization work for Windows OS
/// Get the user name, computer name, user home directory.
- LPTSTR lpszSystemInfo; // pointer to system information string
+ LPWSTR lpszSystemInfo; // pointer to system information string
DWORD cchBuff = BUFSIZE; // size of computer or user name
- TCHAR tchBuffer[BUFSIZE]; // buffer for string
+ WCHAR wchBuffer[BUFSIZE]; // buffer for string
- lpszSystemInfo = tchBuffer;
- if( GetUserNameA(lpszSystemInfo, &cchBuff) )
- strUserName = ::rtl::OUString::createFromAscii( lpszSystemInfo );
+ lpszSystemInfo = wchBuffer;
+ if( GetUserNameW(lpszSystemInfo, &cchBuff) )
+ strUserName = SAL_U(lpszSystemInfo);
- if( GetComputerName(lpszSystemInfo, &cchBuff) )
- strComputerName = ::rtl::OUString::createFromAscii( lpszSystemInfo );
+ cchBuff = BUFSIZE;
+ if( GetComputerNameW(lpszSystemInfo, &cchBuff) )
+ strComputerName = SAL_U(lpszSystemInfo);
/// Get user home directory.
HKEY hRegKey;
- sal_Char PathA[_MAX_PATH];
- if (RegOpenKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hRegKey) == ERROR_SUCCESS)
+ if (RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hRegKey) == ERROR_SUCCESS)
{
- LONG lRet;
- DWORD lSize = sizeof(PathA);
+ sal_Unicode PathW[_MAX_PATH];
+ LSTATUS lRet;
+ DWORD lSize = sizeof(PathW);
DWORD Type;
- lRet = RegQueryValueEx(hRegKey, "AppData", nullptr, &Type, reinterpret_cast<unsigned char *>(PathA), &lSize);
- if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _access( PathA, 0 ) == 0 ) )
+ lRet = RegQueryValueExW(hRegKey, L"AppData", nullptr, &Type, reinterpret_cast<unsigned char *>(PathW), &lSize);
+ if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _waccess( SAL_W(PathW), 0 ) == 0 ) )
{
CPPUNIT_ASSERT_EQUAL_MESSAGE( "#Convert from system path to URL failed.",
- ::osl::File::E_None, ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strConfigDirectory ) );
+ ::osl::File::E_None, ::osl::File::getFileURLFromSystemPath( PathW, strConfigDirectory ) );
}
- lRet = RegQueryValueEx(hRegKey, "Personal", nullptr, &Type, reinterpret_cast<unsigned char *>(PathA), &lSize);
- if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _access( PathA, 0 ) == 0 ) )
+ lSize = sizeof(PathW);
+ lRet = RegQueryValueExW(hRegKey, L"Personal", nullptr, &Type, reinterpret_cast<unsigned char *>(PathW), &lSize);
+ if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _waccess( SAL_W(PathW), 0 ) == 0 ) )
{
CPPUNIT_ASSERT_EQUAL_MESSAGE( "#Convert from system path to URL failed.",
- ::osl::File::E_None, ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strHomeDirectory ) );
+ ::osl::File::E_None, ::osl::File::getFileURLFromSystemPath( PathW, strHomeDirectory ) );
}
RegCloseKey(hRegKey);
@@ -479,7 +481,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
DWORD dwSidRev=SID_REVISION;
DWORD dwCounter;
DWORD dwSidSize;
- sal_Char *Ident;
+ wchar_t *Ident;
/* obtain SidIdentifierAuthority */
psia=GetSidIdentifierAuthority(pSid);
@@ -488,16 +490,16 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
dwSubAuthorities=std::min((int) *GetSidSubAuthorityCount(pSid), 5);
/* buffer length: S-SID_REVISION- + identifierauthority- + subauthorities- + NULL */
- Ident=static_cast<sal_Char *>(malloc(88*sizeof(sal_Char)));
+ Ident=static_cast<wchar_t *>(malloc(88*sizeof(wchar_t)));
/* prepare S-SID_REVISION- */
- dwSidSize=wsprintf(Ident, TEXT("S-%lu-"), dwSidRev);
+ dwSidSize=wsprintfW(Ident, L"S-%lu-", dwSidRev);
/* prepare SidIdentifierAuthority */
if ((psia->Value[0] != 0) || (psia->Value[1] != 0))
{
- dwSidSize+=wsprintf(Ident + strlen(Ident),
- TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"),
+ dwSidSize+=wsprintfW(Ident + wcslen(Ident),
+ L"0x%02hx%02hx%02hx%02hx%02hx%02hx",
(sal_uInt16)psia->Value[0],
(sal_uInt16)psia->Value[1],
(sal_uInt16)psia->Value[2],
@@ -507,8 +509,8 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
}
else
{
- dwSidSize+=wsprintf(Ident + strlen(Ident),
- TEXT("%lu"),
+ dwSidSize+=wsprintfW(Ident + wcslen(Ident),
+ L"%lu",
(sal_uInt32)(psia->Value[5] ) +
(sal_uInt32)(psia->Value[4] << 8) +
(sal_uInt32)(psia->Value[3] << 16) +
@@ -518,11 +520,11 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
/* loop through SidSubAuthorities */
for (dwCounter=0; dwCounter < dwSubAuthorities; dwCounter++)
{
- dwSidSize+=wsprintf(Ident + dwSidSize, TEXT("-%lu"),
+ dwSidSize+=wsprintfW(Ident + dwSidSize, L"-%lu",
*GetSidSubAuthority(pSid, dwCounter) );
}
- strUserID = ::rtl::OUString::createFromAscii( Ident );
+ strUserID = SAL_U(Ident);
free(Ident);
delete [] static_cast<BYTE*>(pSid);