diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-04-04 14:57:45 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-04-04 16:12:11 +0000 |
commit | 9ac98e6e3488e434bf4864ecfb13a121784f640b (patch) | |
tree | b3c9cbf52126fee5864be12e9109f7413e7a0878 /sal/osl/w32/security.cxx | |
parent | 6f995da5a652d993ab253b3363188cd18e289728 (diff) |
Finally switch MSVC to sal_Unicode = char16_t, too
There is lots of (Windows-only) code that relied on sal_Unicode being the same
as wchar_t, and the best change may be different in each case (and doing the
changes may be somewhat error prone). So for now add SAL_U/SAL_W scaffolding
functions to sal/types.h, remove their uses one by one again, and finally drop
those functions again.
Change-Id: I2cc791bd941d089901abb5f6fc2f05fbc49e65ea
Reviewed-on: https://gerrit.libreoffice.org/36077
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal/osl/w32/security.cxx')
-rw-r--r-- | sal/osl/w32/security.cxx | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/sal/osl/w32/security.cxx b/sal/osl/w32/security.cxx index 797feb7371dd..591e6b6b42c9 100644 --- a/sal/osl/w32/security.cxx +++ b/sal/osl/w32/security.cxx @@ -98,11 +98,11 @@ oslSecurityError SAL_CALL osl_loginUser( rtl_uString *strUserName, rtl_uString * oslSecurityError ret; sal_Unicode* strUser; - sal_Unicode* strDomain = _wcsdup(rtl_uString_getStr(strUserName)); + sal_Unicode* strDomain = SAL_U(_wcsdup(SAL_W(rtl_uString_getStr(strUserName)))); HANDLE hUserToken; LUID luid; - if (nullptr != (strUser = wcschr(strDomain, L'/'))) + if (nullptr != (strUser = SAL_U(wcschr(SAL_W(strDomain), L'/')))) *strUser++ = L'\0'; else { @@ -114,7 +114,7 @@ oslSecurityError SAL_CALL osl_loginUser( rtl_uString *strUserName, rtl_uString * OSL_ASSERT(LookupPrivilegeValue(nullptr, SE_TCB_NAME, &luid)); (void) luid; - if (LogonUserW(strUser, strDomain ? strDomain : L"", rtl_uString_getStr(strPasswd), + if (LogonUserW(SAL_W(strUser), strDomain ? SAL_W(strDomain) : L"", SAL_W(rtl_uString_getStr(strPasswd)), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUserToken)) { @@ -123,7 +123,7 @@ oslSecurityError SAL_CALL osl_loginUser( rtl_uString *strUserName, rtl_uString * pSecImpl->m_pNetResource = nullptr; pSecImpl->m_hToken = hUserToken; pSecImpl->m_hProfile = nullptr; - wcscpy(pSecImpl->m_User, strUser); + wcscpy(SAL_W(pSecImpl->m_User), SAL_W(strUser)); *pSecurity = pSecImpl; ret = osl_Security_E_None; @@ -153,25 +153,25 @@ oslSecurityError SAL_CALL osl_loginUserOnFileServer(rtl_uString *strUserName, remoteName = static_cast<sal_Unicode *>(malloc((rtl_uString_getLength(strFileServer) + rtl_uString_getLength(strUserName) + 4) * sizeof(sal_Unicode))); userName = static_cast<sal_Unicode *>(malloc((rtl_uString_getLength(strFileServer) + rtl_uString_getLength(strUserName) + 2) * sizeof(sal_Unicode))); - wcscpy(remoteName, L"\\\\"); - wcscat(remoteName, rtl_uString_getStr(strFileServer)); - wcscat(remoteName, L"\\"); - wcscat(remoteName, rtl_uString_getStr(strUserName)); + wcscpy(SAL_W(remoteName), L"\\\\"); + wcscat(SAL_W(remoteName), SAL_W(rtl_uString_getStr(strFileServer))); + wcscat(SAL_W(remoteName), L"\\"); + wcscat(SAL_W(remoteName), SAL_W(rtl_uString_getStr(strUserName))); - wcscpy(userName, rtl_uString_getStr(strFileServer)); - wcscat(userName, L"\\"); - wcscat(userName, rtl_uString_getStr(strUserName)); + wcscpy(SAL_W(userName), SAL_W(rtl_uString_getStr(strFileServer))); + wcscat(SAL_W(userName), L"\\"); + wcscat(SAL_W(userName), SAL_W(rtl_uString_getStr(strUserName))); netResource.dwScope = RESOURCE_GLOBALNET; netResource.dwType = RESOURCETYPE_DISK; netResource.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE; netResource.dwUsage = RESOURCEUSAGE_CONNECTABLE; netResource.lpLocalName = nullptr; - netResource.lpRemoteName = remoteName; + netResource.lpRemoteName = SAL_W(remoteName); netResource.lpComment = nullptr; netResource.lpProvider = nullptr; - err = WNetAddConnection2W(&netResource, rtl_uString_getStr(strPasswd), userName, 0); + err = WNetAddConnection2W(&netResource, SAL_W(rtl_uString_getStr(strPasswd)), SAL_W(userName), 0); if ((err == NO_ERROR) || (err == ERROR_ALREADY_ASSIGNED)) { @@ -182,7 +182,7 @@ oslSecurityError SAL_CALL osl_loginUserOnFileServer(rtl_uString *strUserName, pSecImpl->m_hToken = nullptr; pSecImpl->m_hProfile = nullptr; - wcscpy(pSecImpl->m_User, rtl_uString_getStr(strUserName)); + wcscpy(SAL_W(pSecImpl->m_User), SAL_W(rtl_uString_getStr(strUserName))); *pSecurity = pSecImpl; @@ -402,9 +402,9 @@ sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent) } Ident=static_cast<sal_Unicode *>(malloc(needed*sizeof(sal_Unicode))); - if (WNetGetUserW(nullptr, Ident, &needed) != NO_ERROR) + if (WNetGetUserW(nullptr, SAL_W(Ident), &needed) != NO_ERROR) { - wcscpy(Ident, L"unknown"); + wcscpy(SAL_W(Ident), L"unknown"); Ident[7] = L'\0'; } @@ -440,7 +440,7 @@ sal_Bool SAL_CALL osl_getHomeDir(oslSecurity Security, rtl_uString **pustrDirect if (pSecImpl->m_pNetResource != nullptr) { - rtl_uString_newFromStr( &ustrSysDir, pSecImpl->m_pNetResource->lpRemoteName); + rtl_uString_newFromStr( &ustrSysDir, SAL_U(pSecImpl->m_pNetResource->lpRemoteName)); bSuccess = osl_File_E_None == osl_getFileURLFromSystemPath( ustrSysDir, pustrDirectory ); } @@ -469,7 +469,7 @@ sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **pustrDire { rtl_uString *ustrSysDir = nullptr; - rtl_uString_newFromStr( &ustrSysDir, pSecImpl->m_pNetResource->lpRemoteName); + rtl_uString_newFromStr( &ustrSysDir, SAL_U(pSecImpl->m_pNetResource->lpRemoteName)); bSuccess = osl_File_E_None == osl_getFileURLFromSystemPath( ustrSysDir, pustrDirectory); if ( ustrSysDir ) @@ -489,7 +489,7 @@ sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **pustrDire if ( !GetSpecialFolder( &ustrFile, CSIDL_APPDATA) ) { - OSL_VERIFY(GetWindowsDirectoryW(sFile, _MAX_DIR) > 0); + OSL_VERIFY(GetWindowsDirectoryW(SAL_W(sFile), _MAX_DIR) > 0); rtl_uString_newFromStr( &ustrFile, sFile); } @@ -555,7 +555,7 @@ sal_Bool SAL_CALL osl_loadUserProfile(oslSecurity Security) ZeroMemory( &pi, sizeof(pi) ); pi.dwSize = sizeof(pi); - pi.lpUserName = rtl_uString_getStr(buffer); + pi.lpUserName = SAL_W(rtl_uString_getStr(buffer)); pi.dwFlags = PI_NOUI; if (fLoadUserProfile(hAccessToken, &pi)) @@ -657,7 +657,7 @@ static bool GetSpecialFolder(rtl_uString **strPath, int nFolder) } else if (pSHGetSpecialFolderPathW) { - if (pSHGetSpecialFolderPathW(GetActiveWindow(), PathW, nFolder, TRUE)) + if (pSHGetSpecialFolderPathW(GetActiveWindow(), SAL_W(PathW), nFolder, TRUE)) { rtl_uString_newFromStr( strPath, PathW); bRet = true; @@ -720,11 +720,11 @@ static bool GetSpecialFolder(rtl_uString **strPath, int nFolder) if (SUCCEEDED(hr)) { - if (pSHGetPathFromIDListW && pSHGetPathFromIDListW(pidl, PathW)) + if (pSHGetPathFromIDListW && pSHGetPathFromIDListW(pidl, SAL_W(PathW))) { /* if directory does not exist, create it */ - if (_waccess(PathW, 0) < 0) - CreateDirectoryW(PathW, nullptr); + if (_waccess(SAL_W(PathW), 0) < 0) + CreateDirectoryW(SAL_W(PathW), nullptr); rtl_uString_newFromStr( strPath, PathW); bRet = true; @@ -833,18 +833,18 @@ static bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **strName SID_NAME_USE sUse; if (LookupAccountSidW(nullptr, reinterpret_cast<PTOKEN_USER>(pInfoBuffer)->User.Sid, - UserName, &nUserName, - DomainName, &nDomainName, &sUse)) + SAL_W(UserName), &nUserName, + SAL_W(DomainName), &nDomainName, &sUse)) { if (bIncludeDomain) { - wcscpy(Name, DomainName); - wcscat(Name, L"/"); - wcscat(Name, UserName); + wcscpy(SAL_W(Name), SAL_W(DomainName)); + wcscat(SAL_W(Name), L"/"); + wcscat(SAL_W(Name), SAL_W(UserName)); } else { - wcscpy(Name, UserName); + wcscpy(SAL_W(Name), SAL_W(UserName)); } } rtl_uString_newFromStr( strName, Name); @@ -862,7 +862,7 @@ static bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **strName WNetGetUserW(nullptr, nullptr, &needed); pNameW = static_cast<sal_Unicode *>(malloc (needed*sizeof(sal_Unicode))); - if (WNetGetUserW(nullptr, pNameW, &needed) == NO_ERROR) + if (WNetGetUserW(nullptr, SAL_W(pNameW), &needed) == NO_ERROR) { rtl_uString_newFromStr( strName, pNameW); @@ -872,7 +872,7 @@ static bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **strName } else if (pSecImpl->m_User[0] != '\0') { - rtl_uString_newFromStr(strName, pSecImpl->m_pNetResource->lpRemoteName); + rtl_uString_newFromStr(strName, SAL_U(pSecImpl->m_pNetResource->lpRemoteName)); if (pNameW) free(pNameW); |