From 974b7fe6dfa8935a2068365e416b8d886f9d2a32 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 30 Sep 2016 15:05:12 +0200 Subject: clang-cl loplugin: sal Change-Id: If04d3f07dc8bffac8887773b5424c09848cd8f1a Reviewed-on: https://gerrit.libreoffice.org/29404 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- sal/osl/all/log.cxx | 2 +- sal/osl/w32/backtrace.cxx | 8 +- sal/osl/w32/conditn.c | 4 +- sal/osl/w32/dllentry.c | 11 +- sal/osl/w32/file-impl.hxx | 25 ++ sal/osl/w32/file.cxx | 177 ++++---- sal/osl/w32/file_dirvol.cxx | 168 +++---- sal/osl/w32/file_url.cxx | 50 +-- sal/osl/w32/file_url.h | 4 +- sal/osl/w32/filetime.h | 50 +++ sal/osl/w32/module.cxx | 100 ++--- sal/osl/w32/nlsupport.c | 4 +- sal/osl/w32/nlsupport.h | 29 ++ sal/osl/w32/path_helper.cxx | 2 +- sal/osl/w32/path_helper.hxx | 4 +- sal/osl/w32/pipe.c | 18 +- sal/osl/w32/process.cxx | 72 +-- sal/osl/w32/procimpl.cxx | 23 +- sal/osl/w32/procimpl.h | 4 +- sal/osl/w32/profile.cxx | 574 ++++++++++++------------ sal/osl/w32/salinit.cxx | 11 +- sal/osl/w32/secimpl.h | 6 +- sal/osl/w32/security.c | 8 +- sal/osl/w32/signal.cxx | 2 +- sal/osl/w32/socket.cxx | 435 ++++++++---------- sal/osl/w32/sockimpl.h | 8 +- sal/osl/w32/tempfile.cxx | 41 +- sal/osl/w32/thread.c | 41 +- sal/osl/w32/thread.h | 29 ++ sal/osl/w32/time.c | 10 +- sal/osl/w32/time.h | 27 ++ sal/qa/osl/process/osl_process.cxx | 24 +- sal/qa/osl/process/osl_process_child.cxx | 2 +- sal/qa/osl/security/osl_Security.cxx | 33 +- sal/qa/osl/setthreadname/test-setthreadname.cxx | 2 +- sal/rtl/alloc_arena.cxx | 6 +- sal/rtl/alloc_cache.cxx | 4 +- sal/systools/win32/uwinapi/sntprintf.c | 6 +- 38 files changed, 1075 insertions(+), 949 deletions(-) create mode 100644 sal/osl/w32/file-impl.hxx create mode 100644 sal/osl/w32/filetime.h create mode 100644 sal/osl/w32/nlsupport.h create mode 100644 sal/osl/w32/thread.h create mode 100644 sal/osl/w32/time.h (limited to 'sal') diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx index da167a74b871..afde14288962 100644 --- a/sal/osl/all/log.cxx +++ b/sal/osl/all/log.cxx @@ -44,7 +44,7 @@ // sal/osl/unx/salinit.cxx::sal_detail_initialize updates this: bool sal_use_syslog; #else -enum { sal_use_syslog = false }; +bool const sal_use_syslog = false; #endif // Avoid the use of other sal code in this file as much as possible, so that diff --git a/sal/osl/w32/backtrace.cxx b/sal/osl/w32/backtrace.cxx index fec366498bc1..b618c6822c51 100644 --- a/sal/osl/w32/backtrace.cxx +++ b/sal/osl/w32/backtrace.cxx @@ -22,19 +22,19 @@ rtl_uString *osl_backtraceAsString() OUStringBuffer aBuf; HANDLE hProcess = GetCurrentProcess(); - SymInitialize( hProcess, NULL, true ); + SymInitialize( hProcess, nullptr, true ); void * aStack[ 512 ]; - sal_uInt32 nFrames = CaptureStackBackTrace( 0, 512, aStack, NULL ); + sal_uInt32 nFrames = CaptureStackBackTrace( 0, 512, aStack, nullptr ); SYMBOL_INFO * pSymbol; - pSymbol = ( SYMBOL_INFO * )calloc( sizeof( SYMBOL_INFO ) + 1024 * sizeof( char ), 1 ); + pSymbol = static_cast(calloc( sizeof( SYMBOL_INFO ) + 1024 * sizeof( char ), 1 )); pSymbol->MaxNameLen = 1024 - 1; pSymbol->SizeOfStruct = sizeof( SYMBOL_INFO ); for( sal_uInt32 i = 0; i < nFrames; i++ ) { - SymFromAddr( hProcess, ( DWORD64 )aStack[ i ], 0, pSymbol ); + SymFromAddr( hProcess, reinterpret_cast(aStack[ i ]), nullptr, pSymbol ); aBuf.append( (sal_Int32)(nFrames - i - 1) ); aBuf.append( ": " ); aBuf.appendAscii( pSymbol->Name ); diff --git a/sal/osl/w32/conditn.c b/sal/osl/w32/conditn.c index 9947929fd7e4..6f90e50672f0 100644 --- a/sal/osl/w32/conditn.c +++ b/sal/osl/w32/conditn.c @@ -35,10 +35,10 @@ oslCondition SAL_CALL osl_createCondition(void) { oslCondition Condition; - Condition= (oslCondition)CreateEvent(0, /* no security */ + Condition= (oslCondition)CreateEvent(NULL, /* no security */ sal_True, /* manual reset */ sal_False, /* initial state not signaled */ - 0); /* automatic name */ + NULL); /* automatic name */ return Condition; diff --git a/sal/osl/w32/dllentry.c b/sal/osl/w32/dllentry.c index 97536ce116be..54133b5ce0f9 100644 --- a/sal/osl/w32/dllentry.c +++ b/sal/osl/w32/dllentry.c @@ -36,10 +36,11 @@ #include "rtllifecycle.h" +#include + // externals extern DWORD g_dwTLSTextEncodingIndex; -extern void SAL_CALL _osl_callThreadKeyCallbackOnThreadDetach(void); extern CRITICAL_SECTION g_ThreadKeyListCS; extern oslMutex g_Mutex; extern oslMutex g_CurrentDirectoryMutex; @@ -69,8 +70,8 @@ _pRawDllMain() */ -static BOOL WINAPI _RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ); -BOOL (WINAPI *_pRawDllMain)(HINSTANCE, DWORD, LPVOID) = _RawDllMain; +static BOOL WINAPI RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ); +BOOL (WINAPI *_pRawDllMain)(HINSTANCE, DWORD, LPVOID) = RawDllMain; #endif @@ -139,7 +140,7 @@ __main (void) static void do_startup( void ) { #else -static BOOL WINAPI _RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) +static BOOL WINAPI RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { (void)hinstDLL; /* avoid warnings */ (void)lpvReserved; /* avoid warnings */ @@ -322,7 +323,7 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) break; case DLL_THREAD_DETACH: - _osl_callThreadKeyCallbackOnThreadDetach( ); + osl_callThreadKeyCallbackOnThreadDetach( ); break; } diff --git a/sal/osl/w32/file-impl.hxx b/sal/osl/w32/file-impl.hxx new file mode 100644 index 000000000000..a34e43301eb0 --- /dev/null +++ b/sal/osl/w32/file-impl.hxx @@ -0,0 +1,25 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SAL_OSL_W32_FILE_IMPL_HXX +#define INCLUDED_SAL_OSL_W32_FILE_IMPL_HXX + +#include + +#include +#include + +#include + +extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle( + HANDLE hFile, sal_uInt32 uFlags); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx index cb12df6fa488..73cb2f8409ed 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -23,6 +23,7 @@ #include "osl/file.hxx" +#include #include "file_url.h" #include "file_error.h" @@ -119,7 +120,7 @@ struct FileHandle_Impl sal_Sequence ** ppSequence, sal_uInt64 * pBytesRead); - oslFileError writeSequence_Impl ( + static oslFileError writeSequence_Impl ( sal_Sequence ** ppSequence, SIZE_T * pnOffset, const void * pBuffer, @@ -134,8 +135,8 @@ struct FileHandle_Impl rtl_cache_type * m_cache; SIZE_T m_bufsiz; - Allocator (Allocator const &); - Allocator & operator= (Allocator const &); + Allocator (Allocator const &) = delete; + Allocator & operator= (Allocator const &) = delete; public: static Allocator & get(); @@ -168,42 +169,45 @@ FileHandle_Impl::Allocator::get() } FileHandle_Impl::Allocator::Allocator() - : m_cache (0), + : m_cache (nullptr), m_bufsiz (0) { SIZE_T const pagesize = FileHandle_Impl::getpagesize(); m_cache = rtl_cache_create ( - "osl_file_buffer_cache", pagesize, 0, 0, 0, 0, 0, 0, 0); - if (0 != m_cache) + "osl_file_buffer_cache", pagesize, 0, nullptr, nullptr, nullptr, + nullptr, nullptr, 0); + if (nullptr != m_cache) m_bufsiz = pagesize; } FileHandle_Impl::Allocator::~Allocator() { - rtl_cache_destroy(m_cache), m_cache = 0; + rtl_cache_destroy(m_cache); + m_cache = nullptr; } void FileHandle_Impl::Allocator::allocate (sal_uInt8 ** ppBuffer, SIZE_T * pnSize) { - OSL_PRECOND((0 != ppBuffer) && (0 != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation"); - *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)), *pnSize = m_bufsiz; + OSL_PRECOND((nullptr != ppBuffer) && (nullptr != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation"); + *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)); + *pnSize = m_bufsiz; } void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer) { - if (0 != pBuffer) + if (nullptr != pBuffer) rtl_cache_free (m_cache, pBuffer); } FileHandle_Impl::Guard::Guard(LPCRITICAL_SECTION pMutex) : m_mutex (pMutex) { - OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::Guard(): null pointer."); + OSL_PRECOND (m_mutex != nullptr, "FileHandle_Impl::Guard::Guard(): null pointer."); ::EnterCriticalSection (m_mutex); } FileHandle_Impl::Guard::~Guard() { - OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::~Guard(): null pointer."); + OSL_PRECOND (m_mutex != nullptr, "FileHandle_Impl::Guard::~Guard(): null pointer."); ::LeaveCriticalSection (m_mutex); } @@ -216,17 +220,18 @@ FileHandle_Impl::FileHandle_Impl(HANDLE hFile) m_bufptr (-1), m_buflen (0), m_bufsiz (0), - m_buffer (0) + m_buffer (nullptr) { ::InitializeCriticalSection (&m_mutex); Allocator::get().allocate (&m_buffer, &m_bufsiz); - if (m_buffer != 0) + if (m_buffer != nullptr) memset (m_buffer, 0, m_bufsiz); } FileHandle_Impl::~FileHandle_Impl() { - Allocator::get().deallocate (m_buffer), m_buffer = 0; + Allocator::get().deallocate (m_buffer); + m_buffer = nullptr; ::DeleteCriticalSection (&m_mutex); } @@ -267,7 +272,7 @@ sal_uInt64 FileHandle_Impl::getSize() const oslFileError FileHandle_Impl::setSize (sal_uInt64 uSize) { LARGE_INTEGER nDstPos; nDstPos.QuadPart = sal::static_int_cast< LONGLONG >(uSize); - if (!::SetFilePointerEx(m_hFile, nDstPos, 0, FILE_BEGIN)) + if (!::SetFilePointerEx(m_hFile, nDstPos, nullptr, FILE_BEGIN)) return oslTranslateFileError( GetLastError() ); if (!::SetEndOfFile(m_hFile)) @@ -275,7 +280,7 @@ oslFileError FileHandle_Impl::setSize (sal_uInt64 uSize) m_size = uSize; nDstPos.QuadPart = m_offset; - if (!::SetFilePointerEx(m_hFile, nDstPos, 0, FILE_BEGIN)) + if (!::SetFilePointerEx(m_hFile, nDstPos, nullptr, FILE_BEGIN)) return oslTranslateFileError( GetLastError() ); return osl_File_E_None; @@ -298,13 +303,13 @@ oslFileError FileHandle_Impl::readAt ( if (nOffset != m_offset) { LARGE_INTEGER liOffset; liOffset.QuadPart = nOffset; - if (!::SetFilePointerEx(m_hFile, liOffset, 0, FILE_BEGIN)) + if (!::SetFilePointerEx(m_hFile, liOffset, nullptr, FILE_BEGIN)) return oslTranslateFileError( GetLastError() ); m_offset = nOffset; } DWORD dwDone = 0; - if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, 0)) + if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, nullptr)) return oslTranslateFileError( GetLastError() ); m_offset += dwDone; @@ -329,13 +334,13 @@ oslFileError FileHandle_Impl::writeAt ( if (nOffset != m_offset) { LARGE_INTEGER liOffset; liOffset.QuadPart = nOffset; - if (!::SetFilePointerEx (m_hFile, liOffset, 0, FILE_BEGIN)) + if (!::SetFilePointerEx (m_hFile, liOffset, nullptr, FILE_BEGIN)) return oslTranslateFileError( GetLastError() ); m_offset = nOffset; } DWORD dwDone = 0; - if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, 0)) + if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, nullptr)) return oslTranslateFileError( GetLastError() ); m_offset += dwDone; @@ -360,12 +365,12 @@ oslFileError FileHandle_Impl::readFileAt ( { // not seekable (pipe) DWORD dwDone = 0; - if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, 0)) + if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, nullptr)) return oslTranslateFileError( GetLastError() ); *pBytesRead = dwDone; return osl_File_E_None; } - else if (0 == m_buffer) + else if (nullptr == m_buffer) { // not buffered return readAt (nOffset, pBuffer, nBytesRequested, pBytesRead); @@ -384,7 +389,8 @@ oslFileError FileHandle_Impl::readFileAt ( oslFileError result = syncFile(); if (result != osl_File_E_None) return result; - m_bufptr = -1, m_buflen = 0; + m_bufptr = -1; + m_buflen = 0; if (nBytesRequested >= m_bufsiz) { @@ -394,7 +400,8 @@ oslFileError FileHandle_Impl::readFileAt ( if (result != osl_File_E_None) return result; - nBytesRequested -= sal::static_int_cast< DWORD >(uDone), *pBytesRead += uDone; + nBytesRequested -= sal::static_int_cast< DWORD >(uDone); + *pBytesRead += uDone; return osl_File_E_None; } @@ -403,7 +410,8 @@ oslFileError FileHandle_Impl::readFileAt ( result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); if (result != osl_File_E_None) return result; - m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone); + m_bufptr = bufptr; + m_buflen = sal::static_int_cast< SIZE_T >(uDone); } if (bufpos >= m_buflen) { @@ -413,7 +421,9 @@ oslFileError FileHandle_Impl::readFileAt ( SIZE_T const bytes = std::min(m_buflen - bufpos, (SIZE_T) nBytesRequested); memcpy (&(buffer[*pBytesRead]), &(m_buffer[bufpos]), bytes); - nBytesRequested -= bytes, *pBytesRead += bytes, nOffset += bytes; + nBytesRequested -= bytes; + *pBytesRead += bytes; + nOffset += bytes; } return osl_File_E_None; } @@ -434,12 +444,12 @@ oslFileError FileHandle_Impl::writeFileAt ( { // not seekable (pipe) DWORD dwDone = 0; - if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, 0)) + if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, nullptr)) return oslTranslateFileError( GetLastError() ); *pBytesWritten = dwDone; return osl_File_E_None; } - else if (0 == m_buffer) + else if (nullptr == m_buffer) { // not buffered return writeAt(nOffset, pBuffer, nBytesToWrite, pBytesWritten); @@ -457,7 +467,8 @@ oslFileError FileHandle_Impl::writeFileAt ( oslFileError result = syncFile(); if (result != osl_File_E_None) return result; - m_bufptr = -1, m_buflen = 0; + m_bufptr = -1; + m_buflen = 0; if (nBytesToWrite >= m_bufsiz) { @@ -469,7 +480,8 @@ oslFileError FileHandle_Impl::writeFileAt ( if (uDone != nBytesToWrite) return osl_File_E_IO; - nBytesToWrite -= sal::static_int_cast< DWORD >(uDone), *pBytesWritten += uDone; + nBytesToWrite -= sal::static_int_cast< DWORD >(uDone); + *pBytesWritten += uDone; return osl_File_E_None; } @@ -478,12 +490,15 @@ oslFileError FileHandle_Impl::writeFileAt ( result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); if (result != osl_File_E_None) return result; - m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone); + m_bufptr = bufptr; + m_buflen = sal::static_int_cast< SIZE_T >(uDone); } SIZE_T const bytes = std::min(m_bufsiz - bufpos, (SIZE_T) nBytesToWrite); memcpy (&(m_buffer[bufpos]), &(buffer[*pBytesWritten]), bytes); - nBytesToWrite -= bytes, *pBytesWritten += bytes, nOffset += bytes; + nBytesToWrite -= bytes; + *pBytesWritten += bytes; + nOffset += bytes; m_buflen = std::max(m_buflen, bufpos + bytes); m_state |= STATE_MODIFIED; @@ -513,7 +528,8 @@ oslFileError FileHandle_Impl::readLineAt ( if (result != osl_File_E_None) return result; - m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone); + m_bufptr = bufptr; + m_buflen = sal::static_int_cast< SIZE_T >(uDone); } static int const LINE_STATE_BEGIN = 0; @@ -535,7 +551,8 @@ oslFileError FileHandle_Impl::readLineAt ( ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos); if (result != osl_File_E_None) return result; - *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos; + *pBytesRead += curpos - bufpos; + nOffset += curpos - bufpos; } bufptr = nOffset / m_bufsiz * m_bufsiz; @@ -546,10 +563,12 @@ oslFileError FileHandle_Impl::readLineAt ( result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); if (result != osl_File_E_None) return result; - m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone); + m_bufptr = bufptr; + m_buflen = sal::static_int_cast< SIZE_T >(uDone); } - bufpos = sal::static_int_cast< SIZE_T >(nOffset - m_bufptr), curpos = bufpos; + bufpos = sal::static_int_cast< SIZE_T >(nOffset - m_bufptr); + curpos = bufpos; if (bufpos >= m_buflen) break; } @@ -585,20 +604,22 @@ oslFileError FileHandle_Impl::readLineAt ( if (state != LINE_STATE_BEGIN) { /* store (and eat) the newline char */ - m_buffer[curpos] = 0x0A, curpos++; + m_buffer[curpos] = 0x0A; + curpos++; /* flush buffer to sequence */ result = writeSequence_Impl ( ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos - 1); if (result != osl_File_E_None) return result; - *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos; + *pBytesRead += curpos - bufpos; + nOffset += curpos - bufpos; } break; } } - result = writeSequence_Impl (ppSequence, &dstpos, 0, 0); + result = writeSequence_Impl (ppSequence, &dstpos, nullptr, 0); if (result != osl_File_E_None) return result; if (0 < dstpos) @@ -625,12 +646,13 @@ oslFileError FileHandle_Impl::writeSequence_Impl ( /* resize sequence */ rtl_byte_sequence_realloc(ppSequence, nElements); } - if (*ppSequence != 0) + if (*ppSequence != nullptr) { /* fill sequence */ - memcpy(&((*ppSequence)->elements[*pnOffset]), pBuffer, nBytes), *pnOffset += nBytes; + memcpy(&((*ppSequence)->elements[*pnOffset]), pBuffer, nBytes); + *pnOffset += nBytes; } - return (*ppSequence != 0) ? osl_File_E_None : osl_File_E_NOMEM; + return (*ppSequence != nullptr) ? osl_File_E_None : osl_File_E_NOMEM; } oslFileError FileHandle_Impl::syncFile() @@ -657,14 +679,14 @@ SAL_CALL osl_createFileHandleFromOSHandle ( sal_uInt32 uFlags) { if ( !IsValidHandle(hFile) ) - return 0; // EINVAL + return nullptr; // EINVAL FileHandle_Impl * pImpl = new FileHandle_Impl(hFile); - if (pImpl == 0) + if (pImpl == nullptr) { // cleanup and fail (void) ::CloseHandle(hFile); - return 0; // ENOMEM + return nullptr; // ENOMEM } /* check for regular file */ @@ -688,7 +710,7 @@ SAL_CALL osl_createFileHandleFromOSHandle ( !((uFlags & osl_File_OpenFlag_Read) || (uFlags & osl_File_OpenFlag_Write)), "sal.osl", "osl_createFileHandleFromOSHandle(): missing read/write access flags"); - return (oslFileHandle)pImpl; + return static_cast(pImpl); } oslFileError @@ -697,8 +719,8 @@ SAL_CALL osl_openFile( oslFileHandle * pHandle, sal_uInt32 uFlags ) { - rtl_uString * strSysPath = 0; - oslFileError result = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); + rtl_uString * strSysPath = nullptr; + oslFileError result = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false ); if (result != osl_File_E_None) return result; @@ -719,7 +741,7 @@ SAL_CALL osl_openFile( HANDLE hFile = CreateFileW( rtl_uString_getStr( strSysPath ), - dwAccess, dwShare, NULL, dwCreation, dwAttributes, NULL ); + dwAccess, dwShare, nullptr, dwCreation, dwAttributes, nullptr ); // @@@ ERROR HANDLING @@@ if ( !IsValidHandle( hFile ) ) @@ -735,7 +757,7 @@ oslFileError SAL_CALL osl_syncFile(oslFileHandle Handle) { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); @@ -754,7 +776,7 @@ oslFileError SAL_CALL osl_closeFile(oslFileHandle Handle) { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; ::EnterCriticalSection (&(pImpl->m_mutex)); @@ -799,16 +821,16 @@ SAL_CALL osl_mapFile( }; FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == ppAddr)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == ppAddr)) return osl_File_E_INVAL; - *ppAddr = 0; + *ppAddr = nullptr; static SIZE_T const nLimit = std::numeric_limits< SIZE_T >::max(); if (uLength > nLimit) return osl_File_E_OVERFLOW; SIZE_T const nLength = sal::static_int_cast< SIZE_T >(uLength); - FileMapping aMap( ::CreateFileMapping (pImpl->m_hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL) ); + FileMapping aMap( ::CreateFileMapping (pImpl->m_hFile, nullptr, SEC_COMMIT | PAGE_READONLY, 0, 0, nullptr) ); if (!IsValidHandle(aMap.m_handle)) return oslTranslateFileError( GetLastError() ); @@ -816,7 +838,7 @@ SAL_CALL osl_mapFile( DWORD const dwOffsetLo = sal::static_int_cast(uOffset & 0xFFFFFFFF); *ppAddr = ::MapViewOfFile( aMap.m_handle, FILE_MAP_READ, dwOffsetHi, dwOffsetLo, nLength ); - if (0 == *ppAddr) + if (nullptr == *ppAddr) return oslTranslateFileError( GetLastError() ); if (uFlags & osl_File_MapFlag_RandomAccess) @@ -830,7 +852,7 @@ SAL_CALL osl_mapFile( * Pagein, touching first byte of each memory page. * Note: volatile disables optimizing the loop away. */ - BYTE * pData (reinterpret_cast(*ppAddr)); + BYTE * pData (static_cast(*ppAddr)); SIZE_T nSize (nLength); volatile BYTE c = 0; @@ -851,7 +873,7 @@ SAL_CALL osl_mapFile( oslFileError SAL_CALL osl_unmapFile(void* pAddr, sal_uInt64 /* uLength */) { - if (0 == pAddr) + if (nullptr == pAddr) return osl_File_E_INVAL; if (!::UnmapViewOfFile (pAddr)) @@ -872,7 +894,7 @@ SAL_CALL osl_readLine( sal_Sequence ** ppSequence) { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == ppSequence)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == ppSequence)) return osl_File_E_INVAL; sal_uInt64 uBytesRead = 0; @@ -893,7 +915,7 @@ SAL_CALL osl_readFile( sal_uInt64 * pBytesRead) { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesRead)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pBuffer) || (nullptr == pBytesRead)) return osl_File_E_INVAL; // read at current filepos; filepos += *pBytesRead; @@ -914,7 +936,7 @@ SAL_CALL osl_writeFile( { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesWritten)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pBuffer) || (nullptr == pBytesWritten)) return osl_File_E_INVAL; // write at current filepos; filepos += *pBytesWritten; @@ -936,7 +958,7 @@ SAL_CALL osl_readFileAt( { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesRead)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pBuffer) || (nullptr == pBytesRead)) return osl_File_E_INVAL; if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE)) return osl_File_E_SPIPE; @@ -961,7 +983,7 @@ SAL_CALL osl_writeFileAt( { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesWritten)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pBuffer) || (nullptr == pBytesWritten)) return osl_File_E_INVAL; if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE)) return osl_File_E_SPIPE; @@ -981,7 +1003,7 @@ SAL_CALL osl_isEndOfFile (oslFileHandle Handle, sal_Bool *pIsEOF) { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pIsEOF)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pIsEOF)) return osl_File_E_INVAL; FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); @@ -993,7 +1015,7 @@ oslFileError SAL_CALL osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos) { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pPos)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pPos)) return osl_File_E_INVAL; FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); @@ -1005,7 +1027,7 @@ oslFileError SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uOffset) { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; static sal_Int64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); @@ -1049,7 +1071,7 @@ SAL_CALL osl_getFileSize (oslFileHandle Handle, sal_uInt64 *pSize) { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pSize)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pSize)) return osl_File_E_INVAL; FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); @@ -1062,7 +1084,7 @@ SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize) { FileHandle_Impl * pImpl = static_cast(Handle); - if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) + if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; if (0 == (pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE)) return osl_File_E_BADF; @@ -1075,7 +1097,8 @@ SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize) oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) return result; - pImpl->m_bufptr = -1, pImpl->m_buflen = 0; + pImpl->m_bufptr = -1; + pImpl->m_buflen = 0; return pImpl->setSize (uSize); } @@ -1084,8 +1107,8 @@ SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize) oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath ) { - rtl_uString *strSysPath = NULL; - oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); + rtl_uString *strSysPath = nullptr; + oslFileError error = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false ); if ( osl_File_E_None == error ) { @@ -1101,11 +1124,11 @@ oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath ) oslFileError SAL_CALL osl_copyFile( rtl_uString* strPath, rtl_uString *strDestPath ) { - rtl_uString *strSysPath = NULL, *strSysDestPath = NULL; - oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); + rtl_uString *strSysPath = nullptr, *strSysDestPath = nullptr; + oslFileError error = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false ); if ( osl_File_E_None == error ) - error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False ); + error = osl_getSystemPathFromFileURL_( strDestPath, &strSysDestPath, false ); if ( osl_File_E_None == error ) { @@ -1128,11 +1151,11 @@ oslFileError SAL_CALL osl_copyFile( rtl_uString* strPath, rtl_uString *strDestPa oslFileError SAL_CALL osl_moveFile( rtl_uString* strPath, rtl_uString *strDestPath ) { - rtl_uString *strSysPath = NULL, *strSysDestPath = NULL; - oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); + rtl_uString *strSysPath = nullptr, *strSysDestPath = nullptr; + oslFileError error = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false ); if ( osl_File_E_None == error ) - error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False ); + error = osl_getSystemPathFromFileURL_( strDestPath, &strSysDestPath, false ); if ( osl_File_E_None == error ) { diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx index 33ef6e37f042..a2fbfc15a21f 100644 --- a/sal/osl/w32/file_dirvol.cxx +++ b/sal/osl/w32/file_dirvol.cxx @@ -24,6 +24,7 @@ #include "osl/file.h" #include "file_url.h" +#include #include #include "file_error.h" @@ -44,7 +45,7 @@ static const wchar_t UNC_PREFIX[] = L"\\\\"; static const wchar_t BACKSLASH = '\\'; static const wchar_t SLASH = '/'; -extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime) +BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime) { SYSTEMTIME BaseSysTime; FILETIME BaseFileTime; @@ -68,15 +69,15 @@ extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime __int64 timeValue; __int64 localTime = cpTimeVal->Seconds*(__int64)10000000+cpTimeVal->Nanosec/100; - *(__int64 *)&FTime=localTime; - fSuccess = 0 <= (timeValue= *((__int64 *)&BaseFileTime) + *((__int64 *) &FTime)); + osl::detail::setFiletime(FTime, localTime); + fSuccess = 0 <= (timeValue= osl::detail::getFiletime(BaseFileTime) + osl::detail::getFiletime(FTime)); if (fSuccess) - *(__int64 *)pFTime=timeValue; + osl::detail::setFiletime(*pFTime, timeValue); } return fSuccess; } -extern "C" BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal) +BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal) { SYSTEMTIME BaseSysTime; FILETIME BaseFileTime; @@ -95,7 +96,7 @@ extern "C" BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal { __int64 Value; - fSuccess = 0 <= (Value = *((__int64 *)cpFTime) - *((__int64 *)&BaseFileTime)); + fSuccess = 0 <= (Value = osl::detail::getFiletime(*cpFTime) - osl::detail::getFiletime(BaseFileTime)); if ( fSuccess ) { @@ -112,7 +113,7 @@ namespace /* private */ struct Component { Component() : - begin_(0), end_(0) + begin_(nullptr), end_(nullptr) {} bool isPresent() const @@ -199,7 +200,7 @@ oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handl { if ( Handle ) { - rtl_uString_acquire( (rtl_uString *)Handle ); + rtl_uString_acquire( static_cast(Handle) ); return osl_File_E_None; } else @@ -210,7 +211,7 @@ oslFileError SAL_CALL osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handl { if ( Handle ) { - rtl_uString_release( (rtl_uString *)Handle ); + rtl_uString_release( static_cast(Handle) ); return osl_File_E_None; } else @@ -221,7 +222,7 @@ oslFileError SAL_CALL osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle { if ( Handle && pstrPath ) { - rtl_uString_assign( pstrPath, (rtl_uString *)Handle ); + rtl_uString_assign( pstrPath, static_cast(Handle) ); return osl_File_E_None; } else @@ -269,7 +270,7 @@ typedef struct tagDRIVEENUM static HANDLE WINAPI OpenLogicalDrivesEnum() { - LPDRIVEENUM pEnum = (LPDRIVEENUM)HeapAlloc( GetProcessHeap(), 0, sizeof(DRIVEENUM) ); + LPDRIVEENUM pEnum = static_cast(HeapAlloc( GetProcessHeap(), 0, sizeof(DRIVEENUM) )); if ( pEnum ) { DWORD dwNumCopied = GetLogicalDriveStrings( (sizeof(pEnum->cBuffer) - 1) / sizeof(WCHAR), pEnum->cBuffer ); @@ -285,13 +286,13 @@ static HANDLE WINAPI OpenLogicalDrivesEnum() pEnum = nullptr; } } - return pEnum ? (HANDLE)pEnum : INVALID_HANDLE_VALUE; + return pEnum ? static_cast(pEnum) : INVALID_HANDLE_VALUE; } static BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPWSTR lpBuffer) { BOOL fSuccess = FALSE; - LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum; + LPDRIVEENUM pEnum = static_cast(hEnum); if ( pEnum ) { @@ -315,7 +316,7 @@ static BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPWSTR lpBuffer) static BOOL WINAPI CloseLogicalDrivesEnum(HANDLE hEnum) { BOOL fSuccess = FALSE; - LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum; + LPDRIVEENUM pEnum = static_cast(hEnum); if ( pEnum ) { @@ -343,7 +344,7 @@ static HANDLE WINAPI OpenDirectory( rtl_uString* pPath) sal_uInt32 nLen = rtl_uString_getLength( pPath ); if ( nLen ) { - const WCHAR* pSuffix = 0; + const WCHAR* pSuffix = nullptr; sal_uInt32 nSuffLen = 0; if ( pPath->buffer[nLen - 1] != L'\\' ) @@ -357,12 +358,12 @@ static HANDLE WINAPI OpenDirectory( rtl_uString* pPath) nSuffLen = 3; } - WCHAR* szFileMask = reinterpret_cast< WCHAR* >( rtl_allocateMemory( sizeof( WCHAR ) * ( nLen + nSuffLen + 1 ) ) ); + WCHAR* szFileMask = static_cast< WCHAR* >( rtl_allocateMemory( sizeof( WCHAR ) * ( nLen + nSuffLen + 1 ) ) ); _tcscpy( szFileMask, rtl_uString_getStr( pPath ) ); _tcscat( szFileMask, pSuffix ); - pDirectory = (LPDIRECTORY)HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY)); + pDirectory = static_cast(HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY))); pDirectory->hFind = FindFirstFile(szFileMask, &pDirectory->aFirstData); if (!IsValidHandle(pDirectory->hFind)) @@ -377,13 +378,13 @@ static HANDLE WINAPI OpenDirectory( rtl_uString* pPath) } } - return (HANDLE)pDirectory; + return static_cast(pDirectory); } BOOL WINAPI EnumDirectory(HANDLE hDirectory, LPWIN32_FIND_DATA pFindData) { BOOL fSuccess = FALSE; - LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory; + LPDIRECTORY pDirectory = static_cast(hDirectory); if ( pDirectory ) { @@ -418,7 +419,7 @@ BOOL WINAPI EnumDirectory(HANDLE hDirectory, LPWIN32_FIND_DATA pFindData) static BOOL WINAPI CloseDirectory(HANDLE hDirectory) { BOOL fSuccess = FALSE; - LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory; + LPDIRECTORY pDirectory = static_cast(hDirectory); if (pDirectory) { @@ -444,12 +445,12 @@ static oslFileError osl_openLocalRoot( *pDirectory = nullptr; - error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysPath, sal_False ); + error = osl_getSystemPathFromFileURL_( strDirectoryPath, &strSysPath, false ); if ( osl_File_E_None == error ) { Directory_Impl *pDirImpl; - pDirImpl = reinterpret_cast(rtl_allocateMemory( sizeof(Directory_Impl))); + pDirImpl = static_cast(rtl_allocateMemory( sizeof(Directory_Impl))); ZeroMemory( pDirImpl, sizeof(Directory_Impl) ); rtl_uString_newFromString( &pDirImpl->m_pDirectoryPath, strSysPath ); @@ -461,8 +462,8 @@ static oslFileError osl_openLocalRoot( sal_uInt32 nLen = rtl_uString_getLength( pDirImpl->m_pDirectoryPath ); if ( nLen && pDirImpl->m_pDirectoryPath->buffer[nLen - 1] != L'\\' ) { - rtl_uString* pCurDir = 0; - rtl_uString* pBackSlash = 0; + rtl_uString* pCurDir = nullptr; + rtl_uString* pBackSlash = nullptr; rtl_uString_assign( &pCurDir, pDirImpl->m_pDirectoryPath ); rtl_uString_newFromAscii( &pBackSlash, "\\" ); @@ -479,7 +480,7 @@ static oslFileError osl_openLocalRoot( */ if ( pDirImpl->hEnumDrives != INVALID_HANDLE_VALUE ) { - *pDirectory = (oslDirectory)pDirImpl; + *pDirectory = static_cast(pDirImpl); error = osl_File_E_None; } else @@ -489,11 +490,11 @@ static oslFileError osl_openLocalRoot( if ( pDirImpl->m_pDirectoryPath ) { rtl_uString_release( pDirImpl->m_pDirectoryPath ); - pDirImpl->m_pDirectoryPath = 0; + pDirImpl->m_pDirectoryPath = nullptr; } rtl_freeMemory(pDirImpl); - pDirImpl = 0; + pDirImpl = nullptr; } error = oslTranslateFileError( GetLastError() ); @@ -513,7 +514,7 @@ static oslFileError SAL_CALL osl_openFileDirectory( return osl_File_E_INVAL; *pDirectory = nullptr; - Directory_Impl *pDirImpl = reinterpret_cast(rtl_allocateMemory(sizeof(Directory_Impl))); + Directory_Impl *pDirImpl = static_cast(rtl_allocateMemory(sizeof(Directory_Impl))); ZeroMemory( pDirImpl, sizeof(Directory_Impl) ); rtl_uString_newFromString( &pDirImpl->m_pDirectoryPath, strDirectoryPath ); @@ -525,8 +526,8 @@ static oslFileError SAL_CALL osl_openFileDirectory( sal_uInt32 nLen = rtl_uString_getLength( pDirImpl->m_pDirectoryPath ); if ( nLen && pDirImpl->m_pDirectoryPath->buffer[nLen - 1] != L'\\' ) { - rtl_uString* pCurDir = 0; - rtl_uString* pBackSlash = 0; + rtl_uString* pCurDir = nullptr; + rtl_uString* pBackSlash = nullptr; rtl_uString_assign( &pCurDir, pDirImpl->m_pDirectoryPath ); rtl_uString_newFromAscii( &pBackSlash, "\\" ); @@ -545,13 +546,14 @@ static oslFileError SAL_CALL osl_openFileDirectory( if ( pDirImpl->m_pDirectoryPath ) { rtl_uString_release( pDirImpl->m_pDirectoryPath ); - pDirImpl->m_pDirectoryPath = 0; + pDirImpl->m_pDirectoryPath = nullptr; } - rtl_freeMemory(pDirImpl), pDirImpl = 0; + rtl_freeMemory(pDirImpl); + pDirImpl = nullptr; } - *pDirectory = (oslDirectory)(pDirImpl); + *pDirectory = static_cast(pDirImpl); return error; } @@ -577,11 +579,11 @@ static oslFileError SAL_CALL osl_openNetworkServer( { Directory_Impl *pDirImpl; - pDirImpl = reinterpret_cast(rtl_allocateMemory(sizeof(Directory_Impl))); + pDirImpl = static_cast(rtl_allocateMemory(sizeof(Directory_Impl))); ZeroMemory( pDirImpl, sizeof(Directory_Impl) ); pDirImpl->uType = DIRECTORYTYPE_NETROOT; pDirImpl->hDirectory = hEnum; - *pDirectory = (oslDirectory)pDirImpl; + *pDirectory = static_cast(pDirImpl); } return oslTranslateFileError( dwError ); } @@ -602,7 +604,7 @@ static DWORD create_dir_with_callback( if (aDirectoryCreationCallbackFunc) { rtl::OUString url; - _osl_getFileURLFromSystemPath(dir_path, &(url.pData)); + osl_getFileURLFromSystemPath_(dir_path, &(url.pData)); aDirectoryCreationCallbackFunc(pData, url.pData); } return ERROR_SUCCESS; @@ -668,7 +670,7 @@ oslFileError SAL_CALL osl_createDirectoryPath( rtl::OUString sys_path; oslFileError osl_error = - _osl_getSystemPathFromFileURL(aDirectoryUrl, &sys_path.pData, sal_False); + osl_getSystemPathFromFileURL_(aDirectoryUrl, &sys_path.pData, false); if (osl_error != osl_File_E_None) return osl_error; @@ -691,7 +693,7 @@ oslFileError SAL_CALL osl_createDirectory(rtl_uString* strPath) oslFileError osl_createDirectoryWithFlags(rtl_uString * strPath, sal_uInt32) { rtl_uString *strSysPath = nullptr; - oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); + oslFileError error = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false ); if ( osl_File_E_None == error ) { @@ -726,7 +728,7 @@ oslFileError osl_createDirectoryWithFlags(rtl_uString * strPath, sal_uInt32) oslFileError SAL_CALL osl_removeDirectory(rtl_uString* strPath) { rtl_uString *strSysPath = nullptr; - oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); + oslFileError error = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false ); if ( osl_File_E_None == error ) { @@ -751,7 +753,7 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirect rtl_uString *strSysDirectoryPath = nullptr; DWORD dwPathType; - error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysDirectoryPath, sal_False ); + error = osl_getSystemPathFromFileURL_( strDirectoryPath, &strSysDirectoryPath, false ); if ( osl_File_E_None != error ) return error; @@ -773,10 +775,10 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirect static oslFileError SAL_CALL osl_getNextNetResource( oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/ ) { - Directory_Impl *pDirImpl = (Directory_Impl *)Directory; + Directory_Impl *pDirImpl = static_cast(Directory); DirectoryItem_Impl *pItemImpl = nullptr; BYTE buffer[16384]; - LPNETRESOURCEW lpNetResource = (LPNETRESOURCEW)buffer; + LPNETRESOURCEW lpNetResource = reinterpret_cast(buffer); DWORD dwError, dwCount, dwBufSize; if ( !pItem ) @@ -795,13 +797,13 @@ static oslFileError SAL_CALL osl_getNextNetResource( case NO_ERROR: case ERROR_MORE_DATA: { - pItemImpl = reinterpret_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + pItemImpl = static_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); if ( !pItemImpl ) return osl_File_E_NOMEM; ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); pItemImpl->uType = DIRECTORYITEM_DRIVE; - osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); + osl_acquireDirectoryItem( static_cast(pItemImpl) ); wcscpy( pItemImpl->cDriveString, lpNetResource->lpRemoteName ); @@ -818,7 +820,7 @@ static oslFileError SAL_CALL osl_getNextNetResource( static oslFileError SAL_CALL osl_getNextDrive( oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/ ) { - Directory_Impl *pDirImpl = (Directory_Impl *)Directory; + Directory_Impl *pDirImpl = static_cast(Directory); DirectoryItem_Impl *pItemImpl = nullptr; BOOL fSuccess; @@ -829,13 +831,13 @@ static oslFileError SAL_CALL osl_getNextDrive( if ( !pDirImpl ) return osl_File_E_INVAL; - pItemImpl = reinterpret_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + pItemImpl = static_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); if ( !pItemImpl ) return osl_File_E_NOMEM; ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); pItemImpl->uType = DIRECTORYITEM_DRIVE; - osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); + osl_acquireDirectoryItem( static_cast(pItemImpl) ); fSuccess = EnumLogicalDrives( pDirImpl->hEnumDrives, pItemImpl->cDriveString ); if ( fSuccess ) @@ -848,7 +850,7 @@ static oslFileError SAL_CALL osl_getNextDrive( if ( pItemImpl->m_pFullPath ) { rtl_uString_release( pItemImpl->m_pFullPath ); - pItemImpl->m_pFullPath = 0; + pItemImpl->m_pFullPath = nullptr; } rtl_freeMemory( pItemImpl ); @@ -859,7 +861,7 @@ static oslFileError SAL_CALL osl_getNextDrive( static oslFileError SAL_CALL osl_getNextFileItem( oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/) { - Directory_Impl *pDirImpl = (Directory_Impl *)Directory; + Directory_Impl *pDirImpl = static_cast(Directory); DirectoryItem_Impl *pItemImpl = nullptr; BOOL fFound; @@ -870,7 +872,7 @@ static oslFileError SAL_CALL osl_getNextFileItem( if ( !pDirImpl ) return osl_File_E_INVAL; - pItemImpl = reinterpret_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + pItemImpl = static_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); if ( !pItemImpl ) return osl_File_E_NOMEM; @@ -882,13 +884,13 @@ static oslFileError SAL_CALL osl_getNextFileItem( pItemImpl->uType = DIRECTORYITEM_FILE; pItemImpl->nRefCount = 1; - rtl_uString* pTmpFileName = 0; + rtl_uString* pTmpFileName = nullptr; rtl_uString_newFromStr( &pTmpFileName, pItemImpl->FindData.cFileName ); rtl_uString_newConcat( &pItemImpl->m_pFullPath, pDirImpl->m_pDirectoryPath, pTmpFileName ); rtl_uString_release( pTmpFileName ); pItemImpl->bFullPathNormalized = FALSE; - *pItem = (oslDirectoryItem)pItemImpl; + *pItem = static_cast(pItemImpl); return osl_File_E_None; } else @@ -896,7 +898,7 @@ static oslFileError SAL_CALL osl_getNextFileItem( if ( pItemImpl->m_pFullPath ) { rtl_uString_release( pItemImpl->m_pFullPath ); - pItemImpl->m_pFullPath = 0; + pItemImpl->m_pFullPath = nullptr; } rtl_freeMemory( pItemImpl ); @@ -907,7 +909,7 @@ static oslFileError SAL_CALL osl_getNextFileItem( oslFileError SAL_CALL osl_getNextDirectoryItem( oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint) { - Directory_Impl *pDirImpl = (Directory_Impl *)Directory; + Directory_Impl *pDirImpl = static_cast(Directory); /* Assume failure */ @@ -933,7 +935,7 @@ oslFileError SAL_CALL osl_getNextDirectoryItem( oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory) { - Directory_Impl *pDirImpl = (Directory_Impl *)Directory; + Directory_Impl *pDirImpl = static_cast(Directory); oslFileError eError = osl_File_E_INVAL; if ( pDirImpl ) @@ -960,7 +962,7 @@ oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory) if ( pDirImpl->m_pDirectoryPath ) { rtl_uString_release( pDirImpl->m_pDirectoryPath ); - pDirImpl->m_pDirectoryPath = 0; + pDirImpl->m_pDirectoryPath = nullptr; } rtl_freeMemory(pDirImpl); @@ -969,14 +971,14 @@ oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory) } /* Different types of paths */ -typedef enum _PATHTYPE +enum PATHTYPE { PATHTYPE_SYNTAXERROR = 0, PATHTYPE_NETROOT, PATHTYPE_NETSERVER, PATHTYPE_VOLUME, PATHTYPE_FILE -} PATHTYPE; +}; oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirectoryItem *pItem) { @@ -992,7 +994,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector *pItem = nullptr; - error = _osl_getSystemPathFromFileURL( strFilePath, &strSysFilePath, sal_False ); + error = osl_getSystemPathFromFileURL_( strFilePath, &strSysFilePath, false ); if ( osl_File_E_None != error ) return error; @@ -1011,7 +1013,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector case PATHTYPE_NETSERVER: { DirectoryItem_Impl* pItemImpl = - reinterpret_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + static_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); if ( !pItemImpl ) error = osl_File_E_NOMEM; @@ -1021,7 +1023,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); pItemImpl->uType = DIRECTORYITEM_SERVER; - osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); + osl_acquireDirectoryItem( static_cast(pItemImpl) ); rtl_uString_newFromString( &pItemImpl->m_pFullPath, strSysFilePath ); // Assign a title anyway @@ -1042,7 +1044,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector case PATHTYPE_VOLUME: { DirectoryItem_Impl* pItemImpl = - reinterpret_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + static_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); if ( !pItemImpl ) error = osl_File_E_NOMEM; @@ -1052,7 +1054,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); pItemImpl->uType = DIRECTORYITEM_DRIVE; - osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); + osl_acquireDirectoryItem( static_cast(pItemImpl) ); _tcscpy( pItemImpl->cDriveString, strSysFilePath->buffer ); pItemImpl->cDriveString[0] = rtl::toAsciiUpperCase( pItemImpl->cDriveString[0] ); @@ -1079,10 +1081,10 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector if ( hFind != INVALID_HANDLE_VALUE ) { DirectoryItem_Impl *pItemImpl = - reinterpret_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + static_cast(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); - osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); + osl_acquireDirectoryItem( static_cast(pItemImpl) ); CopyMemory( &pItemImpl->FindData, &aFindData, sizeof(WIN32_FIND_DATA) ); rtl_uString_newFromString( &pItemImpl->m_pFullPath, strSysFilePath ); @@ -1108,7 +1110,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item ) { - DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; + DirectoryItem_Impl *pItemImpl = static_cast(Item); if ( !pItemImpl ) return osl_File_E_INVAL; @@ -1119,7 +1121,7 @@ oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item ) oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item ) { - DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; + DirectoryItem_Impl *pItemImpl = static_cast(Item); if ( !pItemImpl ) return osl_File_E_INVAL; @@ -1129,7 +1131,7 @@ oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item ) if ( pItemImpl->m_pFullPath ) { rtl_uString_release( pItemImpl->m_pFullPath ); - pItemImpl->m_pFullPath = 0; + pItemImpl->m_pFullPath = nullptr; } rtl_freeMemory( pItemImpl ); @@ -1141,18 +1143,18 @@ oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item ) sal_Bool SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, oslDirectoryItem b) { - DirectoryItem_Impl *pA = (DirectoryItem_Impl *) a; - DirectoryItem_Impl *pB = (DirectoryItem_Impl *) b; + DirectoryItem_Impl *pA = static_cast(a); + DirectoryItem_Impl *pB = static_cast(b); if (a == b) - return sal_True; + return true; /* same name => same item, unless renaming / moving madness has occurred */ if (pA->m_pFullPath == pB->m_pFullPath) - return sal_True; + return true; // FIXME: as/when/if this is used in anger on Windows we could // do better here. - return sal_False; + return false; } // volume / file info handling functions @@ -1313,8 +1315,8 @@ static void get_volume_space_information( { BOOL ret = GetDiskFreeSpaceEx( path.getStr(), - (PULARGE_INTEGER)&(pInfo->uFreeSpace), - (PULARGE_INTEGER)&(pInfo->uTotalSpace), + reinterpret_cast(&pInfo->uFreeSpace), + reinterpret_cast(&pInfo->uTotalSpace), nullptr); if (ret) @@ -1422,7 +1424,7 @@ oslFileError SAL_CALL osl_getVolumeInformation( return osl_File_E_INVAL; rtl::OUString system_path; - oslFileError error = _osl_getSystemPathFromFileURL(ustrURL, &system_path.pData, sal_False); + oslFileError error = osl_getSystemPathFromFileURL_(ustrURL, &system_path.pData, false); if (osl_File_E_None != error) return error; @@ -1440,7 +1442,7 @@ oslFileError SAL_CALL osl_getVolumeInformation( if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle) { - error = osl_getFileURLFromSystemPath(volume_root.pData, (rtl_uString**)&pInfo->pDeviceHandle); + error = osl_getFileURLFromSystemPath(volume_root.pData, reinterpret_cast(&pInfo->pDeviceHandle)); if (error != osl_File_E_None) return error; pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle; @@ -1452,7 +1454,7 @@ oslFileError SAL_CALL osl_getVolumeInformation( static oslFileError SAL_CALL osl_getDriveInfo( oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask) { - DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; + DirectoryItem_Impl *pItemImpl = static_cast(Item); WCHAR cDrive[3] = TEXT("A:"); WCHAR cRoot[4] = TEXT("A:\\"); @@ -1550,7 +1552,7 @@ static oslFileError SAL_CALL osl_getDriveInfo( static oslFileError SAL_CALL osl_getServerInfo( oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask ) { - DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; + DirectoryItem_Impl *pItemImpl = static_cast(Item); if ( !pItemImpl ) return osl_File_E_INVAL; @@ -1581,7 +1583,7 @@ oslFileError SAL_CALL osl_getFileStatus( oslFileStatus *pStatus, sal_uInt32 uFieldMask ) { - DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; + DirectoryItem_Impl *pItemImpl = static_cast(Item); if ( !pItemImpl ) return osl_File_E_INVAL; @@ -1673,7 +1675,7 @@ oslFileError SAL_CALL osl_getFileStatus( sal_uInt32 nNewLen = GetCaseCorrectPathName( rtl_uString_getStr( pItemImpl->m_pFullPath ), ::osl::mingw_reinterpret_cast( aBuffer ), aBuffer.getBufSizeInSymbols(), - sal_True ); + true ); if ( nNewLen ) { @@ -1703,7 +1705,7 @@ oslFileError SAL_CALL osl_setFileAttributes( BOOL fSuccess; // Converts the normalized path into a systempath - error = _osl_getSystemPathFromFileURL( ustrFileURL, &ustrSysPath, sal_False ); + error = osl_getSystemPathFromFileURL_( ustrFileURL, &ustrSysPath, false ); if ( osl_File_E_None != error ) return error; @@ -1750,7 +1752,7 @@ oslFileError SAL_CALL osl_setFileTime( HANDLE hFile; BOOL fSuccess; - error=_osl_getSystemPathFromFileURL(filePath, &sysPath, sal_False); + error=osl_getSystemPathFromFileURL_(filePath, &sysPath, false); if (error==osl_File_E_INVAL) return error; diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx index 5009082bc11c..ca41be65ca01 100644 --- a/sal/osl/w32/file_url.cxx +++ b/sal/osl/w32/file_url.cxx @@ -43,7 +43,7 @@ // FileURL functions extern "C" oslMutex g_CurrentDirectoryMutex; /* Initialized in dllentry.c */ -oslMutex g_CurrentDirectoryMutex = 0; +oslMutex g_CurrentDirectoryMutex = nullptr; static BOOL IsValidFilePathComponent( LPCWSTR lpComponent, LPCWSTR *lppComponentEnd, DWORD dwFlags) @@ -483,19 +483,19 @@ DWORD GetCaseCorrectPathName( return 0; } -static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedURL ) +static bool osl_decodeURL_( rtl_String* strUTF8, rtl_uString** pstrDecodedURL ) { sal_Char *pBuffer; const sal_Char *pSrcEnd; const sal_Char *pSrc; sal_Char *pDest; sal_Int32 nSrcLen; - sal_Bool bValidEncoded = sal_True; /* Assume success */ + bool bValidEncoded = true; /* Assume success */ /* The resulting decoded string length is shorter or equal to the source length */ nSrcLen = rtl_string_getLength(strUTF8); - pBuffer = reinterpret_cast(rtl_allocateMemory(nSrcLen + 1)); + pBuffer = static_cast(rtl_allocateMemory(nSrcLen + 1)); pDest = pBuffer; pSrc = rtl_string_getStr(strUTF8); @@ -521,7 +521,7 @@ static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedUR /* The chars are path delimiters and must not be encoded */ if ( 0 == aChar || '\\' == aChar || '/' == aChar || ':' == aChar ) - bValidEncoded = sal_False; + bValidEncoded = false; else *pDest++ = aChar; } @@ -529,7 +529,7 @@ static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedUR case '\0': case '#': case '?': - bValidEncoded = sal_False; + bValidEncoded = false; break; default: *pDest++ = *pSrc++; @@ -542,7 +542,7 @@ static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedUR if ( bValidEncoded ) { rtl_string2UString( pstrDecodedURL, pBuffer, rtl_str_getLength(pBuffer), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS ); - OSL_ASSERT(*pstrDecodedURL != 0); + OSL_ASSERT(*pstrDecodedURL != nullptr); } rtl_freeMemory( pBuffer ); @@ -550,7 +550,7 @@ static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedUR return bValidEncoded; } -static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL ) +static void osl_encodeURL_( rtl_uString *strURL, rtl_String **pstrEncodedURL ) { /* Encode non ascii characters within the URL */ @@ -563,7 +563,7 @@ static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL ) rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS ); - pszEncodedURL = (sal_Char*) rtl_allocateMemory( (rtl_string_getLength( strUTF8 ) * 3 + 1) * sizeof(sal_Char) ); + pszEncodedURL = static_cast(rtl_allocateMemory( (rtl_string_getLength( strUTF8 ) * 3 + 1) * sizeof(sal_Char) )); pURLDest = pszEncodedURL; pURLScan = rtl_string_getStr( strUTF8 ); @@ -619,13 +619,13 @@ static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL ) rtl_freeMemory( pszEncodedURL ); } -oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **pustrPath, sal_Bool bAllowRelative ) +oslFileError osl_getSystemPathFromFileURL_( rtl_uString *strURL, rtl_uString **pustrPath, sal_Bool bAllowRelative ) { rtl_String *strUTF8 = nullptr; rtl_uString *strDecodedURL = nullptr; rtl_uString *strTempPath = nullptr; sal_uInt32 nDecodedLen; - sal_Bool bValidEncoded; + bool bValidEncoded; oslFileError nError = osl_File_E_INVAL; /* Assume failure */ /* If someone hasn't encoded the complete URL we convert it to UTF8 now to prevent from @@ -641,7 +641,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p , "sal.osl" ,"osl_getSystemPathFromFileURL: \"" << rtl::OUString(strURL) << "\" is not encoded !!!"); - bValidEncoded = _osl_decodeURL( strUTF8, &strDecodedURL ); + bValidEncoded = osl_decodeURL_( strUTF8, &strDecodedURL ); /* Release the encoded UTF8 string */ rtl_string_release( strUTF8 ); @@ -687,7 +687,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p sal_uInt32 nNewLen = GetCaseCorrectPathName( pDecodedURL + nSkip, ::osl::mingw_reinterpret_cast(aBuf), aBuf.getBufSizeInSymbols(), - sal_False ); + false ); if ( nNewLen <= MAX_PATH - 12 || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, WSTR_SYSTEM_ROOT_PATH, SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1, SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ) @@ -755,7 +755,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p return nError; } -oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** pstrURL ) +oslFileError osl_getFileURLFromSystemPath_( rtl_uString* strPath, rtl_uString** pstrURL ) { oslFileError nError = osl_File_E_INVAL; /* Assume failure */ rtl_uString *strTempURL = nullptr; @@ -843,11 +843,11 @@ oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** rtl_String *strEncodedURL = nullptr; /* Encode the URL */ - _osl_encodeURL( strTempURL, &strEncodedURL ); + osl_encodeURL_( strTempURL, &strEncodedURL ); /* Provide URL via unicode string */ rtl_string2UString( pstrURL, rtl_string_getStr(strEncodedURL), rtl_string_getLength(strEncodedURL), RTL_TEXTENCODING_ASCII_US, OUSTRING_TO_OSTRING_CVTFLAGS ); - OSL_ASSERT(*pstrURL != 0); + OSL_ASSERT(*pstrURL != nullptr); rtl_string_release( strEncodedURL ); } @@ -863,13 +863,13 @@ oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** oslFileError SAL_CALL osl_getFileURLFromSystemPath( rtl_uString* ustrPath, rtl_uString** pustrURL ) { - return _osl_getFileURLFromSystemPath( ustrPath, pustrURL ); + return osl_getFileURLFromSystemPath_( ustrPath, pustrURL ); } oslFileError SAL_CALL osl_getSystemPathFromFileURL( rtl_uString *ustrURL, rtl_uString **pustrPath) { - return _osl_getSystemPathFromFileURL( ustrURL, pustrPath, sal_True ); + return osl_getSystemPathFromFileURL_( ustrURL, pustrPath, true ); } oslFileError SAL_CALL osl_searchFileURL( @@ -882,12 +882,12 @@ oslFileError SAL_CALL osl_searchFileURL( oslFileError error; /* First try to interpret the file name as an URL even a relative one */ - error = _osl_getSystemPathFromFileURL( ustrFileName, &ustrUNCPath, sal_True ); + error = osl_getSystemPathFromFileURL_( ustrFileName, &ustrUNCPath, true ); /* So far we either have an UNC path or something invalid Now create a system path */ if ( osl_File_E_None == error ) - error = _osl_getSystemPathFromFileURL( ustrUNCPath, &ustrSysPath, sal_True ); + error = osl_getSystemPathFromFileURL_( ustrUNCPath, &ustrSysPath, true ); if ( osl_File_E_None == error ) { @@ -911,8 +911,8 @@ oslFileError SAL_CALL osl_searchFileURL( /* +1 is not necessary if we follow MSDN documentation but for robustness we do so */ nBufferLength = dwResult + 1; lpBuffer = lpBuffer ? - reinterpret_cast(rtl_reallocateMemory(lpBuffer, nBufferLength * sizeof(WCHAR))) : - reinterpret_cast(rtl_allocateMemory(nBufferLength * sizeof(WCHAR))); + static_cast(rtl_reallocateMemory(lpBuffer, nBufferLength * sizeof(WCHAR))) : + static_cast(rtl_allocateMemory(nBufferLength * sizeof(WCHAR))); dwResult = SearchPath( lpszSearchPath, lpszSearchFile, nullptr, nBufferLength, lpBuffer, &lpszFilePart ); } while ( dwResult && dwResult >= nBufferLength ); @@ -962,14 +962,14 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uStr if ( ustrBaseURL && ustrBaseURL->length ) { - eError = _osl_getSystemPathFromFileURL( ustrBaseURL, &ustrBaseSysPath, sal_False ); + eError = osl_getSystemPathFromFileURL_( ustrBaseURL, &ustrBaseSysPath, false ); OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with relative or invalid base URL" ); - eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_True ); + eError = osl_getSystemPathFromFileURL_( ustrRelativeURL, &ustrRelSysPath, true ); } else { - eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_False ); + eError = osl_getSystemPathFromFileURL_( ustrRelativeURL, &ustrRelSysPath, false ); OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with empty base URL and/or invalid relative URL" ); } diff --git a/sal/osl/w32/file_url.h b/sal/osl/w32/file_url.h index 0f51b4c9b50a..ccb99fc56b33 100644 --- a/sal/osl/w32/file_url.h +++ b/sal/osl/w32/file_url.h @@ -70,13 +70,13 @@ DWORD GetCaseCorrectPathName ( BOOL bCheckExistence ); -oslFileError _osl_getSystemPathFromFileURL ( +oslFileError osl_getSystemPathFromFileURL_ ( rtl_uString * strURL, rtl_uString ** pustrPath, sal_Bool bAllowRelative ); -oslFileError _osl_getFileURLFromSystemPath ( +oslFileError osl_getFileURLFromSystemPath_ ( rtl_uString * strPath, rtl_uString ** pstrURL ); diff --git a/sal/osl/w32/filetime.h b/sal/osl/w32/filetime.h new file mode 100644 index 000000000000..130dd8ec6ced --- /dev/null +++ b/sal/osl/w32/filetime.h @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SAL_OSL_W32_FILETIME_H +#define INCLUDED_SAL_OSL_W32_FILETIME_H + +#include + +#include + +#include + +#if defined __cplusplus +extern "C" { +#endif + +BOOL TimeValueToFileTime(TimeValue const * cpTimeVal, FILETIME * pFTime); + +BOOL FileTimeToTimeValue(FILETIME const * cpFTime, TimeValue * pTimeVal); + +#if defined __cplusplus +} +#endif + +#if defined __cplusplus + +namespace osl { namespace detail { + +inline __int64 getFiletime(FILETIME const & ft) { + return (DWORD64(ft.dwHighDateTime) << 32) | ft.dwLowDateTime; +} + +inline void setFiletime(FILETIME & ft, __int64 value) { + ft.dwHighDateTime = value >> 32; + ft.dwLowDateTime = value & 0xFFFFFFFF; +} + +} } + +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx index e88810b61819..f6bba2e40a40 100644 --- a/sal/osl/w32/module.cxx +++ b/sal/osl/w32/module.cxx @@ -43,11 +43,11 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM #if OSL_DEBUG_LEVEL < 2 UINT errorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); #endif - rtl_uString* Module = NULL; - oslModule ret = 0; + rtl_uString* Module = nullptr; + oslModule ret = nullptr; oslFileError nError; - SAL_INFO( "sal.osl", "osl_loadModule: " << OUString((sal_Unicode*)strModuleName->buffer, wcslen(strModuleName->buffer)) ); + SAL_INFO( "sal.osl", "osl_loadModule: " << OUString(strModuleName->buffer, wcslen(strModuleName->buffer)) ); OSL_ASSERT(strModuleName); nError = osl_getSystemPathFromFileURL(strModuleName, &Module); @@ -57,8 +57,8 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM h = LoadLibraryW(reinterpret_cast(Module->buffer)); - if (h == NULL) - h = LoadLibraryExW(reinterpret_cast(Module->buffer), NULL, + if (h == nullptr) + h = LoadLibraryExW(reinterpret_cast(Module->buffer), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); //In case of long path names (\\?\c:\...) try to shorten the filename. @@ -66,7 +66,7 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM //In case the path is to long, the function will fail. However, the error //code can be different. For example, it returned ERROR_FILENAME_EXCED_RANGE //on Windows XP and ERROR_INSUFFICIENT_BUFFER on Windows 7 (64bit) - if (h == NULL && Module->length > 260) + if (h == nullptr && Module->length > 260) { std::vector vec(Module->length + 1); DWORD len = GetShortPathNameW(reinterpret_cast(Module->buffer), @@ -75,13 +75,13 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM { h = LoadLibraryW(reinterpret_cast(&vec[0])); - if (h == NULL) - h = LoadLibraryExW(reinterpret_cast(&vec[0]), NULL, + if (h == nullptr) + h = LoadLibraryExW(reinterpret_cast(&vec[0]), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); } } - ret = (oslModule) h; + ret = static_cast(h); rtl_uString_release(Module); #if OSL_DEBUG_LEVEL < 2 SetErrorMode(errorMode); @@ -99,17 +99,17 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR HMODULE h; UINT errorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); - oslModule ret = 0; + oslModule ret = nullptr; SAL_INFO( "sal.osl", "osl_loadModule: " << pModuleName ); OSL_ASSERT(pModuleName); h = LoadLibrary(pModuleName); - if (h == NULL) - h = LoadLibraryEx(pModuleName, NULL, + if (h == nullptr) + h = LoadLibraryEx(pModuleName, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); - ret = (oslModule) h; + ret = static_cast(h); SetErrorMode(errorMode); return ret; @@ -128,15 +128,15 @@ oslModule osl_loadModuleRelativeAscii( sal_Bool SAL_CALL osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult) { - LPCWSTR pName = pModuleName ? reinterpret_cast(pModuleName->buffer) : NULL; + LPCWSTR pName = pModuleName ? reinterpret_cast(pModuleName->buffer) : nullptr; HMODULE h = GetModuleHandleW(pName); if( h ) { - *pResult = (oslModule) h; - return sal_True; + *pResult = static_cast(h); + return true; } - return sal_False; + return false; } /*****************************************************************************/ @@ -144,7 +144,7 @@ osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult) /*****************************************************************************/ void SAL_CALL osl_unloadModule(oslModule Module) { - FreeLibrary((HMODULE)Module); + FreeLibrary(static_cast(Module)); } /*****************************************************************************/ @@ -160,7 +160,7 @@ void* SAL_CALL osl_getSymbol(oslModule Module, rtl_uString *strSymbolName) #pragma warning(push) #pragma warning(disable:4054) #endif - return (void*)(osl_getFunctionSymbol(Module, strSymbolName)); + return reinterpret_cast(osl_getFunctionSymbol(Module, strSymbolName)); #ifdef _MSC_VER #pragma warning(pop) #endif @@ -171,7 +171,7 @@ void* SAL_CALL osl_getSymbol(oslModule Module, rtl_uString *strSymbolName) /*****************************************************************************/ oslGenericFunction SAL_CALL osl_getFunctionSymbol( oslModule Module, rtl_uString *strSymbolName ) { - rtl_String *symbolName = NULL; + rtl_String *symbolName = nullptr; oslGenericFunction address; OSL_ASSERT(Module); @@ -197,10 +197,10 @@ oslGenericFunction SAL_CALL osl_getFunctionSymbol( oslModule Module, rtl_uString oslGenericFunction SAL_CALL osl_getAsciiFunctionSymbol( oslModule Module, const sal_Char *pSymbol ) { - oslGenericFunction fncAddr = NULL; + oslGenericFunction fncAddr = nullptr; if( pSymbol ) - fncAddr=(oslGenericFunction)GetProcAddress((HMODULE) Module, pSymbol); + fncAddr=reinterpret_cast(GetProcAddress(static_cast(Module), pSymbol)); return fncAddr; } @@ -256,9 +256,9 @@ typedef BOOL (WINAPI *SymGetModuleInfo_PROC)( BTW: We are using ANSI function because not all version of IMAGEHLP.DLL contain Unicode support */ -static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **pustrURL ) +static bool SAL_CALL osl_addressGetModuleURL_NT4_( void *pv, rtl_uString **pustrURL ) { - sal_Bool bSuccess = sal_False; /* Assume failure */ + bool bSuccess = false; /* Assume failure */ /* IMAGEHELP.DLL has a bug that it recursivly scans subdirectories of the root when calling SymInitialize(), so we preferr DBGHELP.DLL @@ -275,23 +275,23 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **p SymInitialize_PROC lpfnSymInitialize; SymCleanup_PROC lpfnSymCleanup; - lpfnSymInitialize = (SymInitialize_PROC)GetProcAddress( hModImageHelp, "SymInitialize" ); - lpfnSymCleanup = (SymCleanup_PROC)GetProcAddress( hModImageHelp, "SymCleanup" ); - lpfnSymGetModuleInfo = (SymGetModuleInfo_PROC)GetProcAddress( hModImageHelp, "SymGetModuleInfo" ); + lpfnSymInitialize = reinterpret_cast(GetProcAddress( hModImageHelp, "SymInitialize" )); + lpfnSymCleanup = reinterpret_cast(GetProcAddress( hModImageHelp, "SymCleanup" )); + lpfnSymGetModuleInfo = reinterpret_cast(GetProcAddress( hModImageHelp, "SymGetModuleInfo" )); if ( lpfnSymInitialize && lpfnSymCleanup && lpfnSymGetModuleInfo ) { IMAGEHLP_MODULE ModuleInfo; ::osl::LongPathBuffer< sal_Char > aModuleFileName( MAX_LONG_PATH ); - LPSTR lpSearchPath = NULL; + LPSTR lpSearchPath = nullptr; - if ( GetModuleFileNameA( NULL, aModuleFileName, aModuleFileName.getBufSizeInSymbols() ) ) + if ( GetModuleFileNameA( nullptr, aModuleFileName, aModuleFileName.getBufSizeInSymbols() ) ) { char *pLastBkSlash = strrchr( aModuleFileName, '\\' ); if ( pLastBkSlash && - pLastBkSlash > (sal_Char*)aModuleFileName + pLastBkSlash > static_cast(aModuleFileName) && *(pLastBkSlash - 1) != ':' && *(pLastBkSlash - 1) != '\\' ) @@ -306,7 +306,7 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **p ZeroMemory( &ModuleInfo, sizeof(ModuleInfo) ); ModuleInfo.SizeOfStruct = sizeof(ModuleInfo); - bSuccess = (sal_Bool)(!!lpfnSymGetModuleInfo( GetCurrentProcess(), (DWORD_PTR)pv, &ModuleInfo )); + bSuccess = !!lpfnSymGetModuleInfo( GetCurrentProcess(), reinterpret_cast(pv), &ModuleInfo ); if ( bSuccess ) { @@ -315,17 +315,17 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **p BaseOfImage to a HMODULE (on NT it's the same) and use GetModuleFileName to retrieve the full path of the loaded image */ - if ( ModuleInfo.LoadedImageName[0] || GetModuleFileNameA( (HMODULE)ModuleInfo.BaseOfImage, ModuleInfo.LoadedImageName, sizeof(ModuleInfo.LoadedImageName) ) ) + if ( ModuleInfo.LoadedImageName[0] || GetModuleFileNameA( reinterpret_cast(ModuleInfo.BaseOfImage), ModuleInfo.LoadedImageName, sizeof(ModuleInfo.LoadedImageName) ) ) { - rtl_uString *ustrSysPath = NULL; + rtl_uString *ustrSysPath = nullptr; rtl_string2UString( &ustrSysPath, ModuleInfo.LoadedImageName, strlen(ModuleInfo.LoadedImageName), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); - OSL_ASSERT(ustrSysPath != NULL); + OSL_ASSERT(ustrSysPath != nullptr); osl_getFileURLFromSystemPath( ustrSysPath, pustrURL ); rtl_uString_release( ustrSysPath ); } else - bSuccess = sal_False; + bSuccess = false; } lpfnSymCleanup( GetCurrentProcess() ); @@ -337,11 +337,11 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **p return bSuccess; } -typedef struct _MODULEINFO { +typedef struct MODULEINFO { LPVOID lpBaseOfDll; DWORD SizeOfImage; LPVOID EntryPoint; -} MODULEINFO, *LPMODULEINFO; +} *LPMODULEINFO; typedef BOOL (WINAPI *EnumProcessModules_PROC)( HANDLE hProcess, // handle to the process @@ -359,30 +359,30 @@ typedef BOOL (WINAPI *GetModuleInformation_PROC)( /* This version can fail because PSAPI.DLL is not always part of NT 4 despite MSDN Library 6.0a say so */ -static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pustrURL ) +static bool SAL_CALL osl_addressGetModuleURL_NT_( void *pv, rtl_uString **pustrURL ) { - sal_Bool bSuccess = sal_False; /* Assume failure */ - static HMODULE hModPsapi = NULL; + bool bSuccess = false; /* Assume failure */ + static HMODULE hModPsapi = nullptr; if ( !hModPsapi ) hModPsapi = LoadLibrary( "PSAPI.DLL" ); if ( hModPsapi ) { - EnumProcessModules_PROC lpfnEnumProcessModules = (EnumProcessModules_PROC)GetProcAddress( hModPsapi, "EnumProcessModules" ); - GetModuleInformation_PROC lpfnGetModuleInformation = (GetModuleInformation_PROC)GetProcAddress( hModPsapi, "GetModuleInformation" ); + EnumProcessModules_PROC lpfnEnumProcessModules = reinterpret_cast(GetProcAddress( hModPsapi, "EnumProcessModules" )); + GetModuleInformation_PROC lpfnGetModuleInformation = reinterpret_cast(GetProcAddress( hModPsapi, "GetModuleInformation" )); if ( lpfnEnumProcessModules && lpfnGetModuleInformation ) { DWORD cbNeeded = 0; - HMODULE *lpModules = NULL; + HMODULE *lpModules = nullptr; DWORD nModules = 0; UINT iModule = 0; MODULEINFO modinfo; - lpfnEnumProcessModules( GetCurrentProcess(), NULL, 0, &cbNeeded ); + lpfnEnumProcessModules( GetCurrentProcess(), nullptr, 0, &cbNeeded ); - lpModules = (HMODULE *)_alloca( cbNeeded ); + lpModules = static_cast(_alloca( cbNeeded )); lpfnEnumProcessModules( GetCurrentProcess(), lpModules, cbNeeded, &cbNeeded ); nModules = cbNeeded / sizeof(HMODULE); @@ -391,10 +391,10 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pu { lpfnGetModuleInformation( GetCurrentProcess(), lpModules[iModule], &modinfo, sizeof(modinfo) ); - if ( (BYTE *)pv >= (BYTE *)modinfo.lpBaseOfDll && (BYTE *)pv < (BYTE *)modinfo.lpBaseOfDll + modinfo.SizeOfImage ) + if ( static_cast(pv) >= static_cast(modinfo.lpBaseOfDll) && static_cast(pv) < static_cast(modinfo.lpBaseOfDll) + modinfo.SizeOfImage ) { ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH ); - rtl_uString *ustrSysPath = NULL; + rtl_uString *ustrSysPath = nullptr; GetModuleFileNameW( lpModules[iModule], ::osl::mingw_reinterpret_cast(aBuffer), aBuffer.getBufSizeInSymbols() ); @@ -402,7 +402,7 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pu osl_getFileURLFromSystemPath( ustrSysPath, pustrURL ); rtl_uString_release( ustrSysPath ); - bSuccess = sal_True; + bSuccess = true; } } } @@ -419,7 +419,7 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pu sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString **pustrURL ) { /* Use ..._NT first because ..._NT4 is much slower */ - return _osl_addressGetModuleURL_NT( pv, pustrURL ) || _osl_addressGetModuleURL_NT4( pv, pustrURL ); + return osl_addressGetModuleURL_NT_( pv, pustrURL ) || osl_addressGetModuleURL_NT4_( pv, pustrURL ); } /*****************************************************************************/ @@ -435,7 +435,7 @@ sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress( oslGenericFunction addr, #pragma warning(push) #pragma warning(disable:4054) #endif - return osl_getModuleURLFromAddress((void*)addr, ppLibraryUrl); + return osl_getModuleURLFromAddress(reinterpret_cast(addr), ppLibraryUrl); #ifdef _MSC_VER #pragma warning(pop) #endif diff --git a/sal/osl/w32/nlsupport.c b/sal/osl/w32/nlsupport.c index 344898893343..afee1593dd09 100644 --- a/sal/osl/w32/nlsupport.c +++ b/sal/osl/w32/nlsupport.c @@ -27,6 +27,8 @@ #endif #include +#include + #include #include #include @@ -209,7 +211,7 @@ rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale( rtl_Locale * pLocale ) * imp_getProcessLocale *****************************************************************************/ -void _imp_getProcessLocale( rtl_Locale ** ppLocale ) +void imp_getProcessLocale( rtl_Locale ** ppLocale ) { WCHAR langCode[ELP_LANGUAGE_FIELD_LENGTH]; WCHAR ctryCode[ELP_COUNTRY_FIELD_LENGTH]; diff --git a/sal/osl/w32/nlsupport.h b/sal/osl/w32/nlsupport.h new file mode 100644 index 000000000000..e42d391ee87c --- /dev/null +++ b/sal/osl/w32/nlsupport.h @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SAL_OSL_W32_NLSUPPORT_H +#define INCLUDED_SAL_OSL_W32_NLSUPPORT_H + +#include + +#include + +#if defined __cplusplus +extern "C" { +#endif + +void imp_getProcessLocale(rtl_Locale ** ppLocale); + +#if defined __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sal/osl/w32/path_helper.cxx b/sal/osl/w32/path_helper.cxx index 2887860f753a..a79373d7078e 100644 --- a/sal/osl/w32/path_helper.cxx +++ b/sal/osl/w32/path_helper.cxx @@ -41,7 +41,7 @@ const rtl::OUString SLASH ("/"); void osl_systemPathEnsureSeparator(/*inout*/ rtl_uString** ppustrPath) { - OSL_PRECOND(ppustrPath && (NULL != *ppustrPath), \ + OSL_PRECOND(ppustrPath && (nullptr != *ppustrPath), \ "osl_systemPathEnsureSeparator: Invalid parameter"); rtl::OUString path(*ppustrPath); diff --git a/sal/osl/w32/path_helper.hxx b/sal/osl/w32/path_helper.hxx index ee77791781c2..a31cd373025e 100644 --- a/sal/osl/w32/path_helper.hxx +++ b/sal/osl/w32/path_helper.hxx @@ -75,7 +75,7 @@ class LongPathBuffer public: explicit LongPathBuffer( sal_uInt32 nCharNum ) - : m_pBuffer( reinterpret_cast( rtl_allocateMemory( nCharNum * sizeof( T ) ) ) ) + : m_pBuffer( static_cast( rtl_allocateMemory( nCharNum * sizeof( T ) ) ) ) , m_nCharNum( nCharNum ) { OSL_ENSURE( m_pBuffer, "Can not allocate the buffer!" ); @@ -85,7 +85,7 @@ public: { if ( m_pBuffer ) rtl_freeMemory( m_pBuffer ); - m_pBuffer = 0; + m_pBuffer = nullptr; } sal_uInt32 getBufSizeInSymbols() diff --git a/sal/osl/w32/pipe.c b/sal/osl/w32/pipe.c index bbcdf098e4b4..7693a25b6196 100644 --- a/sal/osl/w32/pipe.c +++ b/sal/osl/w32/pipe.c @@ -64,7 +64,7 @@ struct oslPipeImpl { /* osl_create/destroy-PipeImpl */ /*****************************************************************************/ -oslPipe __osl_createPipeImpl(void) +oslPipe osl_createPipeImpl(void) { oslPipe pPipe; @@ -83,7 +83,7 @@ oslPipe __osl_createPipeImpl(void) return pPipe; } -void __osl_destroyPipeImpl(oslPipe pPipe) +void osl_destroyPipeImpl(oslPipe pPipe) { if (pPipe != NULL) { @@ -160,7 +160,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options rtl_uString_newConcat(&name, temp, strPipeName); /* alloc memory */ - pPipe= __osl_createPipeImpl(); + pPipe= osl_createPipeImpl(); osl_atomic_increment(&(pPipe->m_Reference)); /* build system pipe name */ @@ -245,7 +245,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options } /* if we reach here something went wrong */ - __osl_destroyPipeImpl(pPipe); + osl_destroyPipeImpl(pPipe); return NULL; } @@ -259,7 +259,7 @@ void SAL_CALL osl_releasePipe( oslPipe pPipe ) { // OSL_ASSERT( pPipe ); - if( 0 == pPipe ) + if( NULL == pPipe ) return; if( 0 == osl_atomic_decrement( &(pPipe->m_Reference) ) ) @@ -267,7 +267,7 @@ void SAL_CALL osl_releasePipe( oslPipe pPipe ) if( ! pPipe->m_bClosed ) osl_closePipe( pPipe ); - __osl_destroyPipeImpl( pPipe ); + osl_destroyPipeImpl( pPipe ); } } @@ -331,16 +331,16 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe) break; // Everything's fine !!! default: // Something went wrong - return 0; + return NULL; } } break; default: // All other error say that somethings going wrong. - return 0; + return NULL; } } - pAcceptedPipe = __osl_createPipeImpl(); + pAcceptedPipe = osl_createPipeImpl(); OSL_ASSERT(pAcceptedPipe); osl_atomic_increment(&(pAcceptedPipe->m_Reference)); diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx index 8c3e1169116d..1b08a2455f5e 100644 --- a/sal/osl/w32/process.cxx +++ b/sal/osl/w32/process.cxx @@ -37,6 +37,8 @@ #include #include +#include +#include #include "procimpl.h" #include "sockimpl.h" #include "file_url.h" @@ -50,10 +52,10 @@ oslProcessError SAL_CALL osl_terminateProcess(oslProcess Process) { - if (Process == NULL) + if (Process == nullptr) return osl_Process_E_Unknown; - if (TerminateProcess(((oslProcessImpl*)Process)->m_hProcess, 0)) + if (TerminateProcess(static_cast(Process)->m_hProcess, 0)) return osl_Process_E_None; return osl_Process_E_Unknown; @@ -69,12 +71,12 @@ oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident) if (hProcess) { - pProcImpl = reinterpret_cast< oslProcessImpl*>( rtl_allocateMemory(sizeof(oslProcessImpl)) ); + pProcImpl = static_cast< oslProcessImpl*>( rtl_allocateMemory(sizeof(oslProcessImpl)) ); pProcImpl->m_hProcess = hProcess; pProcImpl->m_IdProcess = Ident; } else - pProcImpl = NULL; + pProcImpl = nullptr; return pProcImpl; } @@ -83,11 +85,11 @@ oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident) void SAL_CALL osl_freeProcessHandle(oslProcess Process) { - if (Process != NULL) + if (Process != nullptr) { - CloseHandle(((oslProcessImpl*)Process)->m_hProcess); + CloseHandle(static_cast(Process)->m_hProcess); - rtl_freeMemory((oslProcessImpl*)Process); + rtl_freeMemory(Process); } } @@ -99,15 +101,15 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F HANDLE hProcess; DWORD IdProcess; - if (Process == NULL) + if (Process == nullptr) { hProcess = GetCurrentProcess(); IdProcess = GetCurrentProcessId(); } else { - hProcess = ((oslProcessImpl*)Process)->m_hProcess; - IdProcess = ((oslProcessImpl*)Process)->m_IdProcess; + hProcess = static_cast(Process)->m_hProcess; + IdProcess = static_cast(Process)->m_IdProcess; } if (! pInfo || (pInfo->Size != sizeof(oslProcessInfo))) @@ -129,7 +131,7 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F if (Fields & osl_Process_HEAPUSAGE) { - void* lpAddress=0; + void* lpAddress=nullptr; MEMORY_BASIC_INFORMATION Info; pInfo->HeapUsage = 0; @@ -142,9 +144,9 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F if ((Info.State == MEM_COMMIT) && (Info.Type == MEM_PRIVATE)) pInfo->HeapUsage += Info.RegionSize; - lpAddress = (LPBYTE)lpAddress + Info.RegionSize; + lpAddress = static_cast(lpAddress) + Info.RegionSize; } - while ((uintptr_t)lpAddress <= (uintptr_t)0x7FFFFFFF); // 2GB address space + while (reinterpret_cast(lpAddress) <= (uintptr_t)0x7FFFFFFF); // 2GB address space pInfo->Fields |= osl_Process_HEAPUSAGE; } @@ -158,11 +160,11 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F { __int64 Value; - Value = *((__int64 *)&UserTime); + Value = osl::detail::getFiletime(UserTime); pInfo->UserTime.Seconds = (unsigned long) (Value / 10000000L); pInfo->UserTime.Nanosec = (unsigned long)((Value % 10000000L) * 100); - Value = *((__int64 *)&KernelTime); + Value = osl::detail::getFiletime(KernelTime); pInfo->SystemTime.Seconds = (unsigned long) (Value / 10000000L); pInfo->SystemTime.Nanosec = (unsigned long)((Value % 10000000L) * 100); @@ -177,7 +179,7 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F oslProcessError SAL_CALL osl_joinProcess(oslProcess Process) { - return osl_joinProcessWithTimeout(Process, NULL); + return osl_joinProcessWithTimeout(Process, nullptr); } /***************************************************************************/ @@ -188,13 +190,13 @@ oslProcessError SAL_CALL osl_joinProcessWithTimeout(oslProcess Process, const Ti oslProcessError osl_error = osl_Process_E_None; DWORD ret; - if (NULL == Process) + if (nullptr == Process) return osl_Process_E_Unknown; if (pTimeout) timeout = pTimeout->Seconds * 1000 + pTimeout->Nanosec / 1000000L; - ret = WaitForSingleObject(((oslProcessImpl*)Process)->m_hProcess, timeout); + ret = WaitForSingleObject(static_cast(Process)->m_hProcess, timeout); if (WAIT_FAILED == ret) osl_error = osl_Process_E_Unknown; @@ -213,9 +215,9 @@ oslProcessError bootstrap_getExecutableFile(rtl_uString ** ppFileURL) ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH ); DWORD buflen = 0; - if ((buflen = GetModuleFileNameW (0, ::osl::mingw_reinterpret_cast(aBuffer), aBuffer.getBufSizeInSymbols())) > 0) + if ((buflen = GetModuleFileNameW (nullptr, ::osl::mingw_reinterpret_cast(aBuffer), aBuffer.getBufSizeInSymbols())) > 0) { - rtl_uString * pAbsPath = 0; + rtl_uString * pAbsPath = nullptr; rtl_uString_newFromStr_WithLength (&(pAbsPath), aBuffer, buflen); if (pAbsPath) { @@ -247,7 +249,7 @@ struct CommandArgs_Impl static struct CommandArgs_Impl g_command_args = { 0, - 0 + nullptr }; #ifdef _MSC_VER @@ -257,8 +259,8 @@ static struct CommandArgs_Impl g_command_args = static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **) { rtl_uString ** ppArgs = - (rtl_uString**)rtl_allocateZeroMemory (argc * sizeof(rtl_uString*)); - if (ppArgs != 0) + static_cast(rtl_allocateZeroMemory (argc * sizeof(rtl_uString*))); + if (ppArgs != nullptr) { int i; int nArgs; @@ -269,14 +271,14 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **) /* Convert to unicode */ rtl_uString_newFromStr( &(ppArgs[i]), reinterpret_cast(wargv[i]) ); } - if (ppArgs[0] != 0) + if (ppArgs[0] != nullptr) { /* Ensure absolute path */ ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH ); DWORD dwResult = 0; dwResult = SearchPath ( - 0, reinterpret_cast(ppArgs[0]->buffer), L".exe", aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast(aBuffer), 0); + nullptr, reinterpret_cast(ppArgs[0]->buffer), L".exe", aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast(aBuffer), nullptr); if ((0 < dwResult) && (dwResult < aBuffer.getBufSizeInSymbols())) { /* Replace argv[0] with its absolute path */ @@ -284,12 +286,12 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **) &(ppArgs[0]), aBuffer, dwResult); } } - if (ppArgs[0] != 0) + if (ppArgs[0] != nullptr) { /* Convert to FileURL, see @ osl_getExecutableFile() */ - rtl_uString * pResult = 0; + rtl_uString * pResult = nullptr; osl_getFileURLFromSystemPath (ppArgs[0], &pResult); - if (pResult != 0) + if (pResult != nullptr) { rtl_uString_assign (&(ppArgs[0]), pResult); rtl_uString_release (pResult); @@ -369,7 +371,7 @@ void SAL_CALL osl_setCommandArgs (int argc, char ** argv) if (g_command_args.m_nCount == 0) { rtl_uString** ppArgs = osl_createCommandArgs_Impl (argc, argv); - if (ppArgs != 0) + if (ppArgs != nullptr) { g_command_args.m_nCount = argc; g_command_args.m_ppArgs = ppArgs; @@ -418,7 +420,7 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString *ustrVar) // delete the variable from the current process environment // by setting SetEnvironmentVariable's second parameter to NULL LPCWSTR lpName = reinterpret_cast(ustrVar->buffer); - if (SetEnvironmentVariableW(lpName, NULL)) + if (SetEnvironmentVariableW(lpName, nullptr)) { wchar_t *buffer = new wchar_t[wcslen(lpName) + 1 + 1]; wcscpy(buffer, lpName); @@ -448,7 +450,7 @@ oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir if ( dwLen && dwLen < aBuffer.getBufSizeInSymbols() ) { oslFileError eError; - rtl_uString *ustrTemp = NULL; + rtl_uString *ustrTemp = nullptr; rtl_uString_newFromStr_WithLength( &ustrTemp, aBuffer, dwLen ); eError = osl_getFileURLFromSystemPath( ustrTemp, pustrWorkingDir ); @@ -468,9 +470,7 @@ oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir * Process Locale. ***************************************************************************/ -extern "C" void _imp_getProcessLocale( rtl_Locale ** ppLocale ); - -static rtl_Locale * g_theProcessLocale = NULL; +static rtl_Locale * g_theProcessLocale = nullptr; /***************************************************************************/ @@ -479,8 +479,8 @@ oslProcessError SAL_CALL osl_getProcessLocale( rtl_Locale ** ppLocale ) osl_acquireMutex( *osl_getGlobalMutex() ); /* determine the users default locale */ - if( NULL == g_theProcessLocale ) - _imp_getProcessLocale( &g_theProcessLocale ); + if( nullptr == g_theProcessLocale ) + imp_getProcessLocale( &g_theProcessLocale ); /* or return the cached value */ *ppLocale = g_theProcessLocale; diff --git a/sal/osl/w32/procimpl.cxx b/sal/osl/w32/procimpl.cxx index f7b66cabd498..29f766bae7cc 100644 --- a/sal/osl/w32/procimpl.cxx +++ b/sal/osl/w32/procimpl.cxx @@ -32,6 +32,8 @@ # include # undef WIN32_LEAN_AND_MEAN #endif + +#include #include "procimpl.h" #include #include @@ -43,8 +45,6 @@ #include #include -extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle( HANDLE hFile, sal_uInt32 uFlags ); - const sal_Unicode NAME_VALUE_SEPARATOR = TEXT('='); const sal_Char* SPACE = " "; const rtl::OUString ENV_COMSPEC ("COMSPEC"); @@ -201,10 +201,7 @@ namespace /* private */ OSL_ASSERT(envv.getLength()); sal_uInt32 n = envv.getLength() + 1; // copy the final '\0', too - memcpy( - reinterpret_cast(&environment[pos]), - reinterpret_cast(envv.getStr()), - n * sizeof(sal_Unicode)); + memcpy(&environment[pos], envv.getStr(), n * sizeof(sal_Unicode)); pos += n; } environment[pos] = 0; // append a final '\0' @@ -339,7 +336,7 @@ namespace /* private */ if (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(exe_url, exe_path)) return rtl::OUString(); - exe_path = getShortPath(exe_path, rtl::OUString(".exe")); + exe_path = getShortPath(exe_path, ".exe"); if (exe_path.indexOf(' ') != -1) exe_path = quote_string(exe_path); @@ -420,7 +417,7 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( oslFileHandle *pProcessErrorRead) { rtl::OUString exe_path = get_executable_path( - ustrImageName, ustrArguments, nArguments, (Options & osl_Process_SEARCHPATH)); + ustrImageName, ustrArguments, nArguments, (Options & osl_Process_SEARCHPATH) != 0); if (0 == exe_path.getLength()) return osl_Process_E_NotFound; @@ -442,7 +439,7 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( flags |= CREATE_NEW_CONSOLE; command_line.append(batch_processor); - command_line.appendAscii(" /c "); + command_line.append(" /c "); } else // should we return here in case of error? @@ -543,10 +540,10 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( PROCESS_INFORMATION process_info; BOOL bRet = FALSE; - if ((Security != nullptr) && (((oslSecurityImpl*)Security)->m_hToken != nullptr)) + if ((Security != nullptr) && (static_cast(Security)->m_hToken != nullptr)) { bRet = CreateProcessAsUser( - ((oslSecurityImpl*)Security)->m_hToken, + static_cast(Security)->m_hToken, nullptr, const_cast(cmdline.getStr()), nullptr, nullptr, b_inherit_handles, flags, p_environment, p_cwd, &startup_info, &process_info); @@ -574,7 +571,7 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( { CloseHandle(process_info.hThread); - oslProcessImpl* pProcImpl = reinterpret_cast( + oslProcessImpl* pProcImpl = static_cast( rtl_allocateMemory(sizeof(oslProcessImpl))); if (pProcImpl != nullptr) @@ -582,7 +579,7 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( pProcImpl->m_hProcess = process_info.hProcess; pProcImpl->m_IdProcess = process_info.dwProcessId; - *pProcess = (oslProcess)pProcImpl; + *pProcess = static_cast(pProcImpl); if (Options & osl_Process_WAIT) WaitForSingleObject(pProcImpl->m_hProcess, INFINITE); diff --git a/sal/osl/w32/procimpl.h b/sal/osl/w32/procimpl.h index 5dc8e221ef97..0945b45345b3 100644 --- a/sal/osl/w32/procimpl.h +++ b/sal/osl/w32/procimpl.h @@ -17,8 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef _OSL_PROCIMPL_H_ -#define _OSL_PROCIMPL_H_ +#ifndef INCLUDED_SAL_OSL_W32_PROCIMPL_H +#define INCLUDED_SAL_OSL_W32_PROCIMPL_H #include diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx index 9218976934ca..d563a0eadb70 100644 --- a/sal/osl/w32/profile.cxx +++ b/sal/osl/w32/profile.cxx @@ -76,12 +76,12 @@ static inline void copy_ustr_n( void *dest, const void *source, size_t length ) typedef FILETIME osl_TStamp; -typedef enum _osl_TLockMode +enum osl_TLockMode { un_lock, read_lock, write_lock -} osl_TLockMode; +}; -typedef struct _osl_TFile +struct osl_TFile { HANDLE m_Handle; sal_Char* m_pReadPtr; @@ -89,16 +89,16 @@ typedef struct _osl_TFile sal_Char* m_pWriteBuf; sal_uInt32 m_nWriteBufLen; sal_uInt32 m_nWriteBufFree; -} osl_TFile; +}; -typedef struct _osl_TProfileEntry +struct osl_TProfileEntry { sal_uInt32 m_Line; sal_uInt32 m_Offset; sal_uInt32 m_Len; -} osl_TProfileEntry; +}; -typedef struct _osl_TProfileSection +struct osl_TProfileSection { sal_uInt32 m_Line; sal_uInt32 m_Offset; @@ -106,12 +106,12 @@ typedef struct _osl_TProfileSection sal_uInt32 m_NoEntries; sal_uInt32 m_MaxEntries; osl_TProfileEntry* m_Entries; -} osl_TProfileSection; +}; /* Profile-data structure hidden behind oslProfile: */ -typedef struct _osl_TProfileImpl +struct osl_TProfileImpl { sal_uInt32 m_Flags; osl_TFile* m_pFile; @@ -123,7 +123,7 @@ typedef struct _osl_TProfileImpl sal_Char** m_Lines; rtl_uString *m_strFileName; osl_TProfileSection* m_Sections; -} osl_TProfileImpl; +}; /*****************************************************************************/ /* Static Module Function Declarations */ @@ -131,12 +131,12 @@ typedef struct _osl_TProfileImpl static osl_TFile* openFileImpl(rtl_uString * strFileName, oslProfileOption ProfileFlags ); static osl_TStamp closeFileImpl(osl_TFile* pFile); -static sal_Bool lockFile(const osl_TFile* pFile, osl_TLockMode eMode); -static sal_Bool rewindFile(osl_TFile* pFile, sal_Bool bTruncate); +static bool lockFile(const osl_TFile* pFile, osl_TLockMode eMode); +static bool rewindFile(osl_TFile* pFile, bool bTruncate); static osl_TStamp getFileStamp(osl_TFile* pFile); -static sal_Bool getLine(osl_TFile* pFile, const sal_Char *pszLine, int MaxLen); -static sal_Bool putLine(osl_TFile* pFile, const sal_Char *pszLine); +static bool getLine(osl_TFile* pFile, sal_Char *pszLine, int MaxLen); +static bool putLine(osl_TFile* pFile, const sal_Char *pszLine); static const sal_Char* stripBlanks(const sal_Char* String, sal_uInt32* pLen); static const sal_Char* addLine(osl_TProfileImpl* pProfile, const sal_Char* Line); static const sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Line, sal_uInt32 LineNo); @@ -144,25 +144,25 @@ static void removeLine(osl_TProfileImpl* pProfile, sal_uInt32 Li static void setEntry(osl_TProfileImpl* pProfile, osl_TProfileSection* pSection, sal_uInt32 NoEntry, sal_uInt32 Line, const sal_Char* Entry, sal_uInt32 Len); -static sal_Bool addEntry(osl_TProfileImpl* pProfile, osl_TProfileSection *pSection, +static bool addEntry(osl_TProfileImpl* pProfile, osl_TProfileSection *pSection, int Line, const sal_Char* Entry, sal_uInt32 Len); static void removeEntry(osl_TProfileSection *pSection, sal_uInt32 NoEntry); -static sal_Bool addSection(osl_TProfileImpl* pProfile, int Line, const sal_Char* Section, sal_uInt32 Len); +static bool addSection(osl_TProfileImpl* pProfile, int Line, const sal_Char* Section, sal_uInt32 Len); static void removeSection(osl_TProfileImpl* pProfile, osl_TProfileSection *pSection); static osl_TProfileSection* findEntry(osl_TProfileImpl* pProfile, const sal_Char* Section, const sal_Char* Entry, sal_uInt32 *pNoEntry); -static sal_Bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile); -static sal_Bool storeProfile(osl_TProfileImpl* pProfile, sal_Bool bCleanup); -static osl_TProfileImpl* acquireProfile(oslProfile Profile, sal_Bool bWriteable); -static sal_Bool releaseProfile(osl_TProfileImpl* pProfile); -static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile, sal_Unicode *strProfile); +static bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile); +static bool storeProfile(osl_TProfileImpl* pProfile, bool bCleanup); +static osl_TProfileImpl* acquireProfile(oslProfile Profile, bool bWriteable); +static bool releaseProfile(osl_TProfileImpl* pProfile); +static bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile, sal_Unicode *strProfile); -static sal_Bool writeProfileImpl (osl_TFile* pFile); +static bool writeProfileImpl (osl_TFile* pFile); static osl_TFile* osl_openTmpProfileImpl(osl_TProfileImpl*); -static sal_Bool osl_ProfileSwapProfileNames(osl_TProfileImpl*); +static bool osl_ProfileSwapProfileNames(osl_TProfileImpl*); static rtl_uString* osl_ProfileGenerateExtension(rtl_uString* ustrFileName, rtl_uString* ustrExtension); -static sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, rtl_uString** strProfileName); +static bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, rtl_uString** strProfileName); /*****************************************************************************/ /* Exported Module Functions */ @@ -170,9 +170,9 @@ static sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* s oslProfile SAL_CALL osl_openProfile(rtl_uString *strProfileName, sal_uInt32 Flags) { - osl_TFile* pFile = NULL; + osl_TFile* pFile = nullptr; osl_TProfileImpl* pProfile; - rtl_uString *FileName=NULL; + rtl_uString *FileName=nullptr; #ifdef TRACE_OSL_PROFILE OSL_TRACE("In osl_openProfile"); @@ -181,7 +181,7 @@ oslProfile SAL_CALL osl_openProfile(rtl_uString *strProfileName, sal_uInt32 Flag if (rtl_uString_getLength(strProfileName) == 0 ) { - OSL_VERIFY(osl_getProfileName(NULL, NULL, &FileName)); + OSL_VERIFY(osl_getProfileName(nullptr, nullptr, &FileName)); } else { @@ -215,7 +215,7 @@ oslProfile SAL_CALL osl_openProfile(rtl_uString *strProfileName, sal_uInt32 Flag } #endif - if ( (! (Flags & osl_Profile_SYSTEM)) && ( (pFile = openFileImpl(FileName, Flags) ) == NULL ) ) + if ( (! (Flags & osl_Profile_SYSTEM)) && ( (pFile = openFileImpl(FileName, Flags) ) == nullptr ) ) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_openProfile [not opened]"); @@ -223,10 +223,10 @@ oslProfile SAL_CALL osl_openProfile(rtl_uString *strProfileName, sal_uInt32 Flag if( FileName) rtl_uString_release( FileName); - return NULL; + return nullptr; } - pProfile = (osl_TProfileImpl*)calloc(1, sizeof(osl_TProfileImpl)); + pProfile = static_cast(calloc(1, sizeof(osl_TProfileImpl))); pProfile->m_Flags = Flags & FLG_USER; osl_getSystemPathFromFileURL(strProfileName, &pProfile->m_strFileName); @@ -238,7 +238,7 @@ oslProfile SAL_CALL osl_openProfile(rtl_uString *strProfileName, sal_uInt32 Flag loadProfile(pFile, pProfile); - if (pProfile->m_pFile == NULL) + if (pProfile->m_pFile == nullptr) closeFileImpl(pFile); #ifdef TRACE_OSL_PROFILE @@ -252,72 +252,72 @@ oslProfile SAL_CALL osl_openProfile(rtl_uString *strProfileName, sal_uInt32 Flag sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile) { - osl_TProfileImpl* pProfile = (osl_TProfileImpl*)Profile; + osl_TProfileImpl* pProfile = static_cast(Profile); #ifdef TRACE_OSL_PROFILE OSL_TRACE("In osl_closeProfile"); #endif - if ( Profile == 0 ) + if ( Profile == nullptr ) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_closeProfile [profile==0]"); #endif - return sal_False; + return false; } if (! (pProfile->m_Flags & osl_Profile_SYSTEM)) { - pProfile = acquireProfile(Profile,sal_True); + pProfile = acquireProfile(Profile,true); - if ( pProfile != 0 ) + if ( pProfile != nullptr ) { if ( !( pProfile->m_Flags & osl_Profile_READLOCK ) && ( pProfile->m_Flags & FLG_MODIFIED ) ) { - storeProfile(pProfile, sal_False); + storeProfile(pProfile, false); } } else { - pProfile = acquireProfile(Profile,sal_False); + pProfile = acquireProfile(Profile,false); } - if ( pProfile == 0 ) + if ( pProfile == nullptr ) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_closeProfile [pProfile==0]"); #endif - return sal_False; + return false; } - if (pProfile->m_pFile != NULL) + if (pProfile->m_pFile != nullptr) closeFileImpl(pProfile->m_pFile); } - pProfile->m_pFile = NULL; + pProfile->m_pFile = nullptr; rtl_uString_release(pProfile->m_strFileName); - pProfile->m_strFileName = NULL; + pProfile->m_strFileName = nullptr; /* release whole profile data types memory */ if ( pProfile->m_NoLines > 0) { unsigned int index=0; - if ( pProfile->m_Lines != 0 ) + if ( pProfile->m_Lines != nullptr ) { for ( index = 0 ; index < pProfile->m_NoLines ; ++index) { - if ( pProfile->m_Lines[index] != 0 ) + if ( pProfile->m_Lines[index] != nullptr ) { free(pProfile->m_Lines[index]); } } free(pProfile->m_Lines); } - if ( pProfile->m_Sections != 0 ) + if ( pProfile->m_Sections != nullptr ) { for ( index = 0 ; index < pProfile->m_NoSections ; ++index ) { - if ( pProfile->m_Sections[index].m_Entries != 0 ) + if ( pProfile->m_Sections[index].m_Entries != nullptr ) free(pProfile->m_Sections[index].m_Entries); } free(pProfile->m_Sections); @@ -329,34 +329,34 @@ sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile) #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_closeProfile [ok]"); #endif - return sal_True; + return true; } sal_Bool SAL_CALL osl_flushProfile(oslProfile Profile) { - osl_TProfileImpl* pProfile = (osl_TProfileImpl*) Profile; + osl_TProfileImpl* pProfile = static_cast(Profile); osl_TFile* pFile; - sal_Bool bRet = sal_False; + bool bRet = false; #ifdef TRACE_OSL_PROFILE OSL_TRACE("In osl_flushProfile()"); #endif - if ( pProfile == 0 ) + if ( pProfile == nullptr ) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_flushProfile() [pProfile == 0]"); #endif - return sal_False; + return false; } pFile = pProfile->m_pFile; - if ( pFile == 0 || pFile->m_Handle == INVALID_HANDLE_VALUE ) + if ( pFile == nullptr || pFile->m_Handle == INVALID_HANDLE_VALUE ) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_flushProfile() [invalid file]"); #endif - return sal_False; + return false; } if ( pProfile->m_Flags & FLG_MODIFIED ) @@ -364,7 +364,7 @@ sal_Bool SAL_CALL osl_flushProfile(oslProfile Profile) #ifdef DEBUG_OSL_PROFILE OSL_TRACE("swapping to storeprofile"); #endif - bRet = storeProfile(pProfile,sal_False); + bRet = storeProfile(pProfile,false); } #ifdef TRACE_OSL_PROFILE @@ -373,7 +373,7 @@ sal_Bool SAL_CALL osl_flushProfile(oslProfile Profile) return bRet; } -static sal_Bool writeProfileImpl(osl_TFile* pFile) +static bool writeProfileImpl(osl_TFile* pFile) { DWORD BytesWritten=0; BOOL bRet; @@ -382,33 +382,33 @@ static sal_Bool writeProfileImpl(osl_TFile* pFile) OSL_TRACE("In osl_writeProfileImpl()"); #endif - if ( !( pFile != 0 && pFile->m_Handle != INVALID_HANDLE_VALUE ) || ( pFile->m_pWriteBuf == 0 ) ) + if ( !( pFile != nullptr && pFile->m_Handle != INVALID_HANDLE_VALUE ) || ( pFile->m_pWriteBuf == nullptr ) ) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_writeProfileImpl() [invalid args]"); #endif - return sal_False; + return false; } - bRet=WriteFile(pFile->m_Handle, pFile->m_pWriteBuf, pFile->m_nWriteBufLen - pFile->m_nWriteBufFree,&BytesWritten,NULL); + bRet=WriteFile(pFile->m_Handle, pFile->m_pWriteBuf, pFile->m_nWriteBufLen - pFile->m_nWriteBufFree,&BytesWritten,nullptr); if ( bRet == 0 || BytesWritten == 0 ) { OSL_ENSURE(bRet,"WriteFile failed!!!"); OSL_TRACE("write failed '%s'",strerror(errno)); - return sal_False; + return false; } free(pFile->m_pWriteBuf); - pFile->m_pWriteBuf=0; + pFile->m_pWriteBuf=nullptr; pFile->m_nWriteBufLen=0; pFile->m_nWriteBufFree=0; #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_writeProfileImpl() [ok]"); #endif - return sal_True; + return true; } sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile, @@ -417,38 +417,38 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile, const sal_Char* pszDefault) { sal_uInt32 NoEntry; - const sal_Char* pStr = 0; - osl_TProfileImpl* pProfile = 0; + const sal_Char* pStr = nullptr; + osl_TProfileImpl* pProfile = nullptr; #ifdef TRACE_OSL_PROFILE OSL_TRACE("In osl_readProfileString"); #endif - pProfile = acquireProfile(Profile, sal_False); + pProfile = acquireProfile(Profile, false); - if (pProfile == NULL) + if (pProfile == nullptr) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_readProfileString [pProfile==0]"); #endif - return sal_False; + return false; } if (! (pProfile->m_Flags & osl_Profile_SYSTEM)) { osl_TProfileSection* pSec; - if (((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) != NULL) && + if (((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) != nullptr) && (NoEntry < pSec->m_NoEntries) && ((pStr = strchr(pProfile->m_Lines[pSec->m_Entries[NoEntry].m_Line], - '=')) != NULL)) + '=')) != nullptr)) pStr++; else pStr = pszDefault; - if ( pStr != 0 ) + if ( pStr != nullptr ) { - pStr = stripBlanks(pStr, NULL); + pStr = stripBlanks(pStr, nullptr); MaxLen = (MaxLen - 1 < strlen(pStr)) ? (MaxLen - 1) : strlen(pStr); pStr = stripBlanks(pStr, &MaxLen); strncpy(pszString, pStr, MaxLen); @@ -459,26 +459,26 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile, { ::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH ); - WideCharToMultiByte(CP_ACP,0, reinterpret_cast(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL); + WideCharToMultiByte(CP_ACP,0, reinterpret_cast(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), nullptr, nullptr); GetPrivateProfileString(pszSection, pszEntry, pszDefault, pszString, MaxLen, aFileName); } releaseProfile(pProfile); - if ( pStr == 0 ) + if ( pStr == nullptr ) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_readProfileString [pStr==0]"); #endif - return sal_False; + return false; } #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_readProfileString [ok]"); #endif - return sal_True; + return true; } sal_Bool SAL_CALL osl_readProfileBool(oslProfile Profile, @@ -496,12 +496,12 @@ sal_Bool SAL_CALL osl_readProfileBool(oslProfile Profile, if ((stricmp(Line, STR_INI_BOOLYES) == 0) || (stricmp(Line, STR_INI_BOOLON) == 0) || (stricmp(Line, STR_INI_BOOLONE) == 0)) - Default = sal_True; + Default = true; else if ((stricmp(Line, STR_INI_BOOLNO) == 0) || (stricmp(Line, STR_INI_BOOLOFF) == 0) || (stricmp(Line, STR_INI_BOOLZERO) == 0)) - Default = sal_False; + Default = false; } #ifdef TRACE_OSL_PROFILE @@ -526,7 +526,7 @@ sal_uInt32 SAL_CALL osl_readProfileIdent(oslProfile Profile, if (osl_readProfileString(Profile, pszSection, pszEntry, Line, sizeof(Line), "")) { i = 0; - while (Strings[i] != NULL) + while (Strings[i] != nullptr) { if (stricmp(Line, Strings[i]) == 0) { @@ -548,30 +548,30 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, const sal_Char* pszString) { sal_uInt32 i; - sal_Bool bRet = sal_False; + bool bRet = false; sal_uInt32 NoEntry; const sal_Char* pStr; sal_Char Line[4096]; osl_TProfileSection* pSec; - osl_TProfileImpl* pProfile = 0; + osl_TProfileImpl* pProfile = nullptr; #ifdef TRACE_OSL_PROFILE OSL_TRACE("In osl_writeProfileString"); #endif - pProfile = acquireProfile(Profile, sal_True); + pProfile = acquireProfile(Profile, true); - if (pProfile == NULL) + if (pProfile == nullptr) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_writeProfileString [pProfile==0]"); #endif - return sal_False; + return false; } if (! (pProfile->m_Flags & osl_Profile_SYSTEM)) { - if ((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) == NULL) + if ((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) == nullptr) { Line[0] = '\0'; addLine(pProfile, Line); @@ -581,14 +581,14 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, Line[1 + strlen(pszSection)] = ']'; Line[2 + strlen(pszSection)] = '\0'; - if (((pStr = addLine(pProfile, Line)) == NULL) || + if (((pStr = addLine(pProfile, Line)) == nullptr) || (! addSection(pProfile, pProfile->m_NoLines - 1, &pStr[1], strlen(pszSection)))) { releaseProfile(pProfile); #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_writeProfileString [not added]"); #endif - return sal_False; + return false; } pSec = &pProfile->m_Sections[pProfile->m_NoSections - 1]; @@ -607,14 +607,14 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, else i = pSec->m_Line + 1; - if (((pStr = insertLine(pProfile, Line, i)) == NULL) || + if (((pStr = insertLine(pProfile, Line, i)) == nullptr) || (! addEntry(pProfile, pSec, i, pStr, strlen(pszEntry)))) { releaseProfile(pProfile); #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_writeProfileString [not inserted]"); #endif - return sal_False; + return false; } pProfile->m_Flags |= FLG_MODIFIED; @@ -633,7 +633,7 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, { ::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH ); - WideCharToMultiByte(CP_ACP,0, reinterpret_cast(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL); + WideCharToMultiByte(CP_ACP,0, reinterpret_cast(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), nullptr, nullptr); WritePrivateProfileString(pszSection, pszEntry, pszString, aFileName); } @@ -648,7 +648,7 @@ sal_Bool SAL_CALL osl_writeProfileBool(oslProfile Profile, const sal_Char* pszSection, const sal_Char* pszEntry, sal_Bool Value) { - sal_Bool bRet = sal_False; + bool bRet = false; #ifdef TRACE_OSL_PROFILE OSL_TRACE("In osl_writeProfileBool"); @@ -672,16 +672,16 @@ sal_Bool SAL_CALL osl_writeProfileIdent(oslProfile Profile, sal_uInt32 Value) { int i, n; - sal_Bool bRet = sal_False; + bool bRet = false; #ifdef TRACE_OSL_PROFILE OSL_TRACE("In osl_writeProfileIdent"); #endif - for (n = 0; Strings[n] != NULL; n++); + for (n = 0; Strings[n] != nullptr; n++); if ((i = Value - FirstId) >= n) - bRet=sal_False; + bRet=false; else bRet=osl_writeProfileString(Profile, pszSection, pszEntry, Strings[i]); @@ -695,28 +695,28 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile, const sal_Char *pszSection, const sal_Char *pszEntry) { sal_uInt32 NoEntry; - osl_TProfileImpl* pProfile = 0; - sal_Bool bRet = sal_False; + osl_TProfileImpl* pProfile = nullptr; + bool bRet = false; #ifdef TRACE_OSL_PROFILE OSL_TRACE("In osl_removeProfileEntry"); #endif - pProfile = acquireProfile(Profile, sal_True); + pProfile = acquireProfile(Profile, true); - if (pProfile == NULL) + if (pProfile == nullptr) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_removeProfileEntry [pProfile==0]"); #endif - return sal_False; + return false; } if (! (pProfile->m_Flags & osl_Profile_SYSTEM)) { osl_TProfileSection* pSec; - if (((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) != NULL) && + if (((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) != nullptr) && (NoEntry < pSec->m_NoEntries)) { removeLine(pProfile, pSec->m_Entries[NoEntry].m_Line); @@ -739,8 +739,8 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile, { ::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH ); - WideCharToMultiByte(CP_ACP,0, reinterpret_cast(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL); - WritePrivateProfileString(pszSection, pszEntry, NULL, aFileName); + WideCharToMultiByte(CP_ACP,0, reinterpret_cast(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), nullptr, nullptr); + WritePrivateProfileString(pszSection, pszEntry, nullptr, aFileName); } bRet = releaseProfile(pProfile); @@ -755,15 +755,15 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_C { sal_uInt32 i, n = 0; sal_uInt32 NoEntry; - osl_TProfileImpl* pProfile = 0; + osl_TProfileImpl* pProfile = nullptr; #ifdef TRACE_OSL_PROFILE OSL_TRACE("In osl_getProfileSectionEntries"); #endif - pProfile = acquireProfile(Profile, sal_False); + pProfile = acquireProfile(Profile, false); - if (pProfile == NULL) + if (pProfile == nullptr) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_getProfileSectionEntries [pProfile=0]"); @@ -775,7 +775,7 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_C if (! (pProfile->m_Flags & osl_Profile_SYSTEM)) { osl_TProfileSection* pSec; - if ((pSec = findEntry(pProfile, pszSection, "", &NoEntry)) != NULL) + if ((pSec = findEntry(pProfile, pszSection, "", &NoEntry)) != nullptr) { if (MaxLen != 0) { @@ -810,8 +810,8 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_C { ::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH ); - WideCharToMultiByte(CP_ACP,0, reinterpret_cast(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL); - n = GetPrivateProfileString(pszSection, NULL, NULL, pszBuffer, MaxLen, aFileName); + WideCharToMultiByte(CP_ACP,0, reinterpret_cast(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), nullptr, nullptr); + n = GetPrivateProfileString(pszSection, nullptr, nullptr, pszBuffer, MaxLen, aFileName); } releaseProfile(pProfile); @@ -823,22 +823,22 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_C return n; } -sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, rtl_uString** strProfileName) +bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, rtl_uString** strProfileName) { - sal_Bool bFailed; + bool bFailed; ::osl::LongPathBuffer< sal_Unicode > aFile( MAX_LONG_PATH ); ::osl::LongPathBuffer< sal_Unicode > aPath( MAX_LONG_PATH ); sal_uInt32 nFileLen = 0; sal_uInt32 nPathLen = 0; - rtl_uString * strTmp = NULL; + rtl_uString * strTmp = nullptr; oslFileError nError; /* build file name */ if (strName && strName->length) { if( ::sal::static_int_cast< sal_uInt32 >( strName->length ) >= aFile.getBufSizeInSymbols() ) - return sal_False; + return false; copy_ustr_n( aFile, strName->buffer, strName->length+1); nFileLen = strName->length; @@ -846,7 +846,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, if (rtl_ustr_indexOfChar( aFile, L'.' ) == -1) { if (nFileLen + wcslen(STR_INI_EXTENSION) >= aFile.getBufSizeInSymbols()) - return sal_False; + return false; /* add default extension */ copy_ustr_n( aFile + nFileLen, STR_INI_EXTENSION, wcslen(STR_INI_EXTENSION)+1 ); @@ -855,14 +855,14 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, } else { - rtl_uString *strProgName = NULL; + rtl_uString *strProgName = nullptr; sal_Unicode *pProgName; sal_Int32 nOffset = 0; sal_Int32 nLen; sal_Int32 nPos; if (osl_getExecutableFile(&strProgName) != osl_Process_E_None) - return sal_False; + return false; /* remove path and extension from filename */ pProgName = strProgName->buffer; @@ -877,12 +877,12 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, nLen -= 4; if ((nFileLen = nLen - nOffset) >= aFile.getBufSizeInSymbols()) - return sal_False; + return false; copy_ustr_n(aFile, pProgName + nOffset, nFileLen); if (nFileLen + wcslen(STR_INI_EXTENSION) >= aFile.getBufSizeInSymbols()) - return sal_False; + return false; /* add default extension */ copy_ustr_n(aFile + nFileLen, STR_INI_EXTENSION, wcslen(STR_INI_EXTENSION)+1); @@ -892,7 +892,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, } if (aFile[0] == 0) - return sal_False; + return false; /* build directory path */ if (strPath && strPath->length) @@ -903,16 +903,16 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, if ((rtl_ustr_ascii_compare_WithLength(pPath, RTL_CONSTASCII_LENGTH(STR_INI_METAHOME) , STR_INI_METAHOME) == 0) && ((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METAHOME)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METAHOME)] == '/'))) { - rtl_uString * strHome = NULL; + rtl_uString * strHome = nullptr; oslSecurity security = osl_getCurrentSecurity(); bFailed = ! osl_getHomeDir(security, &strHome); osl_freeSecurityHandle(security); - if (bFailed) return sal_False; + if (bFailed) return false; if ( ::sal::static_int_cast< sal_uInt32 >( strHome->length ) >= aPath.getBufSizeInSymbols()) - return sal_False; + return false; copy_ustr_n( aPath, strHome->buffer, strHome->length+1); nPathLen = strHome->length; @@ -923,7 +923,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, nLen -= RTL_CONSTASCII_LENGTH(STR_INI_METAHOME); if (nLen + nPathLen >= aPath.getBufSizeInSymbols()) - return sal_False; + return false; copy_ustr_n(aPath + nPathLen, pPath, nLen+1); nPathLen += nLen; @@ -935,16 +935,16 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, else if ((rtl_ustr_ascii_compare_WithLength(pPath, RTL_CONSTASCII_LENGTH(STR_INI_METACFG), STR_INI_METACFG) == 0) && ((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METACFG)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METACFG)] == '/'))) { - rtl_uString * strConfig = NULL; + rtl_uString * strConfig = nullptr; oslSecurity security = osl_getCurrentSecurity(); bFailed = ! osl_getConfigDir(security, &strConfig); osl_freeSecurityHandle(security); - if (bFailed) return sal_False; + if (bFailed) return false; if ( ::sal::static_int_cast< sal_uInt32 >( strConfig->length ) >= aPath.getBufSizeInSymbols()) - return sal_False; + return false; copy_ustr_n( aPath, strConfig->buffer, strConfig->length+1 ); nPathLen = strConfig->length; @@ -955,7 +955,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, nLen -= RTL_CONSTASCII_LENGTH(STR_INI_METACFG); if (nLen + nPathLen >= aPath.getBufSizeInSymbols()) - return sal_False; + return false; copy_ustr_n(aPath + nPathLen, pPath, nLen+1); nPathLen += nLen; @@ -968,7 +968,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, ((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METASYS)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METASYS)] == '/'))) { if (((nPathLen = GetWindowsDirectoryW(::osl::mingw_reinterpret_cast(aPath), aPath.getBufSizeInSymbols())) == 0) || (nPathLen >= aPath.getBufSizeInSymbols())) - return sal_False; + return false; if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METASYS)) { @@ -976,7 +976,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, nLen -= RTL_CONSTASCII_LENGTH(STR_INI_METASYS); if (nLen + nPathLen >= aPath.getBufSizeInSymbols()) - return sal_False; + return false; copy_ustr_n(aPath + nPathLen, pPath, nLen+1); nPathLen += nLen; @@ -988,7 +988,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METAINS)] == '"') ) ) { if (! lookupProfile(pPath + RTL_CONSTASCII_LENGTH(STR_INI_METAINS), aFile, aPath)) - return sal_False; + return false; nPathLen = rtl_ustr_getLength(aPath); } @@ -999,19 +999,19 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, nPathLen = rtl_ustr_getLength(aPath); } else - return sal_False; + return false; } else { - rtl_uString * strConfigDir = NULL; + rtl_uString * strConfigDir = nullptr; oslSecurity security = osl_getCurrentSecurity(); bFailed = ! osl_getConfigDir(security, &strConfigDir); osl_freeSecurityHandle(security); - if (bFailed) return sal_False; + if (bFailed) return false; if ( ::sal::static_int_cast< sal_uInt32 >( strConfigDir->length ) >= aPath.getBufSizeInSymbols() ) - return sal_False; + return false; copy_ustr_n(aPath, strConfigDir->buffer, strConfigDir->length+1); nPathLen = strConfigDir->length; @@ -1024,7 +1024,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, } if (nPathLen + nFileLen >= aPath.getBufSizeInSymbols()) - return sal_False; + return false; /* append file name */ copy_ustr_n(aPath + nPathLen, aFile, nFileLen+1); @@ -1035,15 +1035,15 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, nError = osl_getFileURLFromSystemPath(strTmp, strProfileName); rtl_uString_release(strTmp); - return (sal_Bool) (nError == osl_File_E_None); + return nError == osl_File_E_None; } sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuffer, sal_uInt32 MaxLen) { sal_uInt32 i, n = 0; - osl_TProfileImpl* pProfile = acquireProfile(Profile, sal_False); + osl_TProfileImpl* pProfile = acquireProfile(Profile, false); - if (pProfile == NULL) + if (pProfile == nullptr) return 0; if (! (pProfile->m_Flags & osl_Profile_SYSTEM)) @@ -1079,7 +1079,7 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuff { ::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH ); - WideCharToMultiByte(CP_ACP,0, reinterpret_cast(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL); + WideCharToMultiByte(CP_ACP,0, reinterpret_cast(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), nullptr, nullptr); n = GetPrivateProfileSectionNames(pszBuffer, MaxLen, aFileName); } @@ -1097,36 +1097,36 @@ static osl_TStamp getFileStamp(osl_TFile* pFile) FILETIME FileTime; if ((pFile->m_Handle == INVALID_HANDLE_VALUE) || - (! GetFileTime(pFile->m_Handle, NULL, NULL, &FileTime))) + (! GetFileTime(pFile->m_Handle, nullptr, nullptr, &FileTime))) memset(&FileTime, 0, sizeof(FileTime)); return FileTime; } -static sal_Bool lockFile(const osl_TFile* pFile, osl_TLockMode eMode) +static bool lockFile(const osl_TFile* pFile, osl_TLockMode eMode) { - sal_Bool status = sal_False; + bool status = false; OVERLAPPED Overlapped; if (pFile->m_Handle == INVALID_HANDLE_VALUE) - return sal_False; + return false; memset(&Overlapped, 0, sizeof(Overlapped)); switch (eMode) { case un_lock: - status = (sal_Bool) UnlockFileEx( + status = UnlockFileEx( pFile->m_Handle, 0, 0xFFFFFFFF, 0, &Overlapped); break; case read_lock: - status = (sal_Bool) LockFileEx( + status = LockFileEx( pFile->m_Handle, 0, 0, 0xFFFFFFFF, 0, &Overlapped); break; case write_lock: - status = (sal_Bool) LockFileEx( + status = LockFileEx( pFile->m_Handle, LOCKFILE_EXCLUSIVE_LOCK, 0, 0xFFFFFFFF, 0, &Overlapped); break; @@ -1137,22 +1137,22 @@ static sal_Bool lockFile(const osl_TFile* pFile, osl_TLockMode eMode) static osl_TFile* openFileImpl(rtl_uString * strFileName, oslProfileOption ProfileFlags ) { - osl_TFile* pFile = reinterpret_cast< osl_TFile*>( calloc( 1, sizeof(osl_TFile) ) ); - sal_Bool bWriteable = sal_False; + osl_TFile* pFile = static_cast< osl_TFile*>( calloc( 1, sizeof(osl_TFile) ) ); + bool bWriteable = false; if ( ProfileFlags & ( osl_Profile_WRITELOCK | osl_Profile_FLUSHWRITE ) ) { #ifdef DEBUG_OSL_PROFILE OSL_TRACE("setting bWriteable to TRUE"); #endif - bWriteable=sal_True; + bWriteable=true; } if (! bWriteable) { pFile->m_Handle = CreateFileW( reinterpret_cast(rtl_uString_getStr( strFileName )), GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); /* mfe: argghh!!! do not check if the file could be openend */ /* default mode expects it that way!!! */ @@ -1164,16 +1164,16 @@ static osl_TFile* openFileImpl(rtl_uString * strFileName, oslProfileOption Profi #endif if ((pFile->m_Handle = CreateFileW( reinterpret_cast(rtl_uString_getStr( strFileName )), GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) + FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, + OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr)) == INVALID_HANDLE_VALUE) { free(pFile); - return NULL; + return nullptr; } } - pFile->m_pWriteBuf=0; + pFile->m_pWriteBuf=nullptr; pFile->m_nWriteBufFree=0; pFile->m_nWriteBufLen=0; @@ -1193,7 +1193,7 @@ static osl_TStamp closeFileImpl(osl_TFile* pFile) { osl_TStamp stamp = {0, 0}; - if ( pFile == 0 ) + if ( pFile == nullptr ) { return stamp; } @@ -1208,7 +1208,7 @@ static osl_TStamp closeFileImpl(osl_TFile* pFile) pFile->m_Handle = INVALID_HANDLE_VALUE; } - if ( pFile->m_pWriteBuf != 0 ) + if ( pFile->m_pWriteBuf != nullptr ) { free(pFile->m_pWriteBuf); } @@ -1218,30 +1218,30 @@ static osl_TStamp closeFileImpl(osl_TFile* pFile) return stamp; } -static sal_Bool rewindFile(osl_TFile* pFile, sal_Bool bTruncate) +static bool rewindFile(osl_TFile* pFile, bool bTruncate) { if (pFile->m_Handle != INVALID_HANDLE_VALUE) { pFile->m_pReadPtr = pFile->m_ReadBuf + sizeof(pFile->m_ReadBuf); - SetFilePointer(pFile->m_Handle, 0, NULL, FILE_BEGIN); + SetFilePointer(pFile->m_Handle, 0, nullptr, FILE_BEGIN); if (bTruncate) SetEndOfFile(pFile->m_Handle); } - return sal_True; + return true; } -static sal_Bool getLine(osl_TFile* pFile, const sal_Char *pszLine, int MaxLen) +static bool getLine(osl_TFile* pFile, sal_Char *pszLine, int MaxLen) { DWORD Max; size_t Free; sal_Char* pChr; - sal_Char* pLine = (sal_Char *)pszLine; + sal_Char* pLine = pszLine; if (pFile->m_Handle == INVALID_HANDLE_VALUE) - return sal_False; + return false; MaxLen -= 1; @@ -1257,10 +1257,10 @@ static sal_Bool getLine(osl_TFile* pFile, const sal_Char *pszLine, int MaxLen) Free = sizeof(pFile->m_ReadBuf) - Bytes; - if (! ReadFile(pFile->m_Handle, &pFile->m_ReadBuf[Bytes], Free, &Max, NULL)) + if (! ReadFile(pFile->m_Handle, &pFile->m_ReadBuf[Bytes], Free, &Max, nullptr)) { *pLine = '\0'; - return sal_False; + return false; } if (Max < Free) @@ -1268,7 +1268,7 @@ static sal_Bool getLine(osl_TFile* pFile, const sal_Char *pszLine, int MaxLen) if ((Max == 0) && (pLine == pszLine)) { *pLine = '\0'; - return sal_False; + return false; } pFile->m_ReadBuf[Bytes + Max] = '\0'; @@ -1309,21 +1309,21 @@ static sal_Bool getLine(osl_TFile* pFile, const sal_Char *pszLine, int MaxLen) } while (MaxLen > 0); - return sal_True; + return true; } -static sal_Bool putLine(osl_TFile* pFile, const sal_Char *pszLine) +static bool putLine(osl_TFile* pFile, const sal_Char *pszLine) { unsigned int Len = strlen(pszLine); - if ( pFile == 0 || pFile->m_Handle == INVALID_HANDLE_VALUE ) + if ( pFile == nullptr || pFile->m_Handle == INVALID_HANDLE_VALUE ) { - return sal_False; + return false; } - if ( pFile->m_pWriteBuf == 0 ) + if ( pFile->m_pWriteBuf == nullptr ) { - pFile->m_pWriteBuf = (sal_Char*) malloc(Len+3); + pFile->m_pWriteBuf = static_cast(malloc(Len+3)); pFile->m_nWriteBufLen = Len+3; pFile->m_nWriteBufFree = Len+3; } @@ -1333,10 +1333,10 @@ static sal_Bool putLine(osl_TFile* pFile, const sal_Char *pszLine) { sal_Char* pTmp; - pTmp=(sal_Char*) realloc(pFile->m_pWriteBuf,( ( pFile->m_nWriteBufLen + Len ) * 2) ); - if ( pTmp == 0 ) + pTmp=static_cast(realloc(pFile->m_pWriteBuf,( ( pFile->m_nWriteBufLen + Len ) * 2) )); + if ( pTmp == nullptr ) { - return sal_False; + return false; } pFile->m_pWriteBuf = pTmp; pFile->m_nWriteBufFree = pFile->m_nWriteBufFree + pFile->m_nWriteBufLen + ( 2 * Len ); @@ -1353,14 +1353,14 @@ static sal_Bool putLine(osl_TFile* pFile, const sal_Char *pszLine) pFile->m_nWriteBufFree-=Len+2; - return sal_True; + return true; } /* platform specific end */ static const sal_Char* stripBlanks(const sal_Char* String, sal_uInt32* pLen) { - if ( (pLen != NULL) && ( *pLen != 0 ) ) + if ( (pLen != nullptr) && ( *pLen != 0 ) ) { while ((String[*pLen - 1] == ' ') || (String[*pLen - 1] == '\t')) (*pLen)--; @@ -1382,7 +1382,7 @@ static const sal_Char* addLine(osl_TProfileImpl* pProfile, const sal_Char* Line) { if (pProfile->m_NoLines >= pProfile->m_MaxLines) { - if (pProfile->m_Lines == NULL) + if (pProfile->m_Lines == nullptr) { pProfile->m_MaxLines = LINES_INI; pProfile->m_Lines = static_cast(calloc(pProfile->m_MaxLines, sizeof(sal_Char *))); @@ -1397,20 +1397,20 @@ static const sal_Char* addLine(osl_TProfileImpl* pProfile, const sal_Char* Line) for ( index = oldmax ; index < pProfile->m_MaxLines ; ++index ) { - pProfile->m_Lines[index]=0; + pProfile->m_Lines[index]=nullptr; } } - if (pProfile->m_Lines == NULL) + if (pProfile->m_Lines == nullptr) { pProfile->m_NoLines = 0; pProfile->m_MaxLines = 0; - return NULL; + return nullptr; } } - if ( pProfile->m_Lines != 0 && pProfile->m_Lines[pProfile->m_NoLines] != 0 ) + if ( pProfile->m_Lines != nullptr && pProfile->m_Lines[pProfile->m_NoLines] != nullptr ) { free(pProfile->m_Lines[pProfile->m_NoLines]); } @@ -1423,7 +1423,7 @@ static const sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Li { if (pProfile->m_NoLines >= pProfile->m_MaxLines) { - if (pProfile->m_Lines == NULL) + if (pProfile->m_Lines == nullptr) { pProfile->m_MaxLines = LINES_INI; pProfile->m_Lines = static_cast(calloc(pProfile->m_MaxLines, sizeof(sal_Char *))); @@ -1439,11 +1439,11 @@ static const sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Li (pProfile->m_MaxLines - pProfile->m_NoLines - 1) * sizeof(sal_Char*)); } - if (pProfile->m_Lines == NULL) + if (pProfile->m_Lines == nullptr) { pProfile->m_NoLines = 0; pProfile->m_MaxLines = 0; - return NULL; + return nullptr; } } @@ -1482,7 +1482,7 @@ static void removeLine(osl_TProfileImpl* pProfile, sal_uInt32 LineNo) if (LineNo < pProfile->m_NoLines) { free(pProfile->m_Lines[LineNo]); - pProfile->m_Lines[LineNo]=0; + pProfile->m_Lines[LineNo]=nullptr; if (pProfile->m_NoLines - LineNo > 1) { sal_uInt32 i, n; @@ -1509,7 +1509,7 @@ static void removeLine(osl_TProfileImpl* pProfile, sal_uInt32 LineNo) } else { - pProfile->m_Lines[LineNo] = 0; + pProfile->m_Lines[LineNo] = nullptr; } pProfile->m_NoLines--; @@ -1530,31 +1530,31 @@ static void setEntry(osl_TProfileImpl* pProfile, osl_TProfileSection* pSection, return; } -static sal_Bool addEntry(osl_TProfileImpl* pProfile, osl_TProfileSection *pSection, +static bool addEntry(osl_TProfileImpl* pProfile, osl_TProfileSection *pSection, int Line, const sal_Char* Entry, sal_uInt32 Len) { - if (pSection != NULL) + if (pSection != nullptr) { if (pSection->m_NoEntries >= pSection->m_MaxEntries) { - if (pSection->m_Entries == NULL) + if (pSection->m_Entries == nullptr) { pSection->m_MaxEntries = ENTRIES_INI; - pSection->m_Entries = (osl_TProfileEntry *)malloc( - pSection->m_MaxEntries * sizeof(osl_TProfileEntry)); + pSection->m_Entries = static_cast(malloc( + pSection->m_MaxEntries * sizeof(osl_TProfileEntry))); } else { pSection->m_MaxEntries += ENTRIES_ADD; - pSection->m_Entries = (osl_TProfileEntry *)realloc(pSection->m_Entries, - pSection->m_MaxEntries * sizeof(osl_TProfileEntry)); + pSection->m_Entries = static_cast(realloc(pSection->m_Entries, + pSection->m_MaxEntries * sizeof(osl_TProfileEntry))); } - if (pSection->m_Entries == NULL) + if (pSection->m_Entries == nullptr) { pSection->m_NoEntries = 0; pSection->m_MaxEntries = 0; - return sal_False; + return false; } } @@ -1564,10 +1564,10 @@ static sal_Bool addEntry(osl_TProfileImpl* pProfile, osl_TProfileSection *pSecti setEntry(pProfile, pSection, pSection->m_NoEntries - 1, Line, Entry, Len); - return sal_True; + return true; } - return sal_False; + return false; } static void removeEntry(osl_TProfileSection *pSection, sal_uInt32 NoEntry) @@ -1590,11 +1590,11 @@ static void removeEntry(osl_TProfileSection *pSection, sal_uInt32 NoEntry) return; } -static sal_Bool addSection(osl_TProfileImpl* pProfile, int Line, const sal_Char* Section, sal_uInt32 Len) +static bool addSection(osl_TProfileImpl* pProfile, int Line, const sal_Char* Section, sal_uInt32 Len) { if (pProfile->m_NoSections >= pProfile->m_MaxSections) { - if (pProfile->m_Sections == NULL) + if (pProfile->m_Sections == nullptr) { pProfile->m_MaxSections = SECTIONS_INI; pProfile->m_Sections = static_cast(calloc(pProfile->m_MaxSections, sizeof(osl_TProfileSection))); @@ -1609,34 +1609,34 @@ static sal_Bool addSection(osl_TProfileImpl* pProfile, int Line, const sal_Char* pProfile->m_MaxSections * sizeof(osl_TProfileSection))); for ( index = oldmax ; index < pProfile->m_MaxSections ; ++index ) { - pProfile->m_Sections[index].m_Entries=0; + pProfile->m_Sections[index].m_Entries=nullptr; } } - if (pProfile->m_Sections == NULL) + if (pProfile->m_Sections == nullptr) { pProfile->m_NoSections = 0; pProfile->m_MaxSections = 0; - return sal_False; + return false; } } pProfile->m_NoSections++; - if ( pProfile->m_Sections[(pProfile->m_NoSections) - 1].m_Entries != 0 ) + if ( pProfile->m_Sections[(pProfile->m_NoSections) - 1].m_Entries != nullptr ) { free(pProfile->m_Sections[(pProfile->m_NoSections) - 1].m_Entries); } - pProfile->m_Sections[pProfile->m_NoSections - 1].m_Entries = NULL; + pProfile->m_Sections[pProfile->m_NoSections - 1].m_Entries = nullptr; pProfile->m_Sections[pProfile->m_NoSections - 1].m_NoEntries = 0; pProfile->m_Sections[pProfile->m_NoSections - 1].m_MaxEntries = 0; - Section = (sal_Char *)stripBlanks(Section, &Len); + Section = stripBlanks(Section, &Len); pProfile->m_Sections[pProfile->m_NoSections - 1].m_Line = Line; pProfile->m_Sections[pProfile->m_NoSections - 1].m_Offset = Section - pProfile->m_Lines[Line]; pProfile->m_Sections[pProfile->m_NoSections - 1].m_Len = Len; - return sal_True; + return true; } static void removeSection(osl_TProfileImpl* pProfile, osl_TProfileSection *pSection) @@ -1646,7 +1646,7 @@ static void removeSection(osl_TProfileImpl* pProfile, osl_TProfileSection *pSect if ((Section = pSection - pProfile->m_Sections) < pProfile->m_NoSections) { free (pSection->m_Entries); - pSection->m_Entries=0; + pSection->m_Entries=nullptr; if (pProfile->m_NoSections - Section > 1) { memmove(&pProfile->m_Sections[Section], &pProfile->m_Sections[Section + 1], @@ -1655,11 +1655,11 @@ static void removeSection(osl_TProfileImpl* pProfile, osl_TProfileSection *pSect memset(&pProfile->m_Sections[pProfile->m_NoSections - 1], 0, (pProfile->m_MaxSections - pProfile->m_NoSections) * sizeof(osl_TProfileSection)); - pProfile->m_Sections[pProfile->m_NoSections - 1].m_Entries = 0; + pProfile->m_Sections[pProfile->m_NoSections - 1].m_Entries = nullptr; } else { - pSection->m_Entries = 0; + pSection->m_Entries = nullptr; } pProfile->m_NoSections--; @@ -1674,10 +1674,10 @@ static osl_TProfileSection* findEntry(osl_TProfileImpl* pProfile, const sal_Char static sal_uInt32 Sect = 0; sal_uInt32 i, n; sal_uInt32 Len; - osl_TProfileSection* pSec = NULL; + osl_TProfileSection* pSec = nullptr; Len = strlen(Section); - Section = (sal_Char *)stripBlanks(Section, &Len); + Section = stripBlanks(Section, &Len); n = Sect; @@ -1715,37 +1715,37 @@ static sal_uInt32 Sect = 0; } } else - pSec = NULL; + pSec = nullptr; return pSec; } -static sal_Bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile) +static bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile) { sal_uInt32 i; - sal_Char* pStr; - sal_Char* pChar; + sal_Char const * pStr; + sal_Char const * pChar; sal_Char Line[4096]; pProfile->m_NoLines = 0; pProfile->m_NoSections = 0; - OSL_VERIFY(rewindFile(pFile, sal_False)); + OSL_VERIFY(rewindFile(pFile, false)); while (getLine(pFile, Line, sizeof(Line))) { if (! addLine(pProfile, Line)) - return sal_False; + return false; } for (i = 0; i < pProfile->m_NoLines; i++) { - pStr = (sal_Char *)stripBlanks(pProfile->m_Lines[i], NULL); + pStr = stripBlanks(pProfile->m_Lines[i], nullptr); if ((*pStr == '\0') || (*pStr == ';')) continue; - if ((*pStr != '[') || ((pChar = strrchr(pStr, ']')) == NULL) || + if ((*pStr != '[') || ((pChar = strrchr(pStr, ']')) == nullptr) || ((pChar - pStr) <= 2)) { /* insert entry */ @@ -1753,31 +1753,31 @@ static sal_Bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile) if (pProfile->m_NoSections < 1) continue; - if ((pChar = strchr(pStr, '=')) == NULL) + if ((pChar = strchr(pStr, '=')) == nullptr) pChar = pStr + strlen(pStr); if (! addEntry(pProfile, &pProfile->m_Sections[pProfile->m_NoSections - 1], i, pStr, pChar - pStr)) - return sal_False; + return false; } else { /* new section */ if (! addSection(pProfile, i, pStr + 1, pChar - pStr - 1)) - return sal_False; + return false; } } - return sal_True; + return true; } -static sal_Bool storeProfile(osl_TProfileImpl* pProfile, sal_Bool bCleanup) +static bool storeProfile(osl_TProfileImpl* pProfile, bool bCleanup) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("In storeProfile"); #endif - if (pProfile->m_Lines != NULL) + if (pProfile->m_Lines != nullptr) { if (pProfile->m_Flags & FLG_MODIFIED) { @@ -1785,12 +1785,12 @@ static sal_Bool storeProfile(osl_TProfileImpl* pProfile, sal_Bool bCleanup) osl_TFile* pTmpFile = osl_openTmpProfileImpl(pProfile); - if ( pTmpFile == 0 ) + if ( pTmpFile == nullptr ) { - return sal_False; + return false; } - OSL_VERIFY(rewindFile(pTmpFile, sal_True)); + OSL_VERIFY(rewindFile(pTmpFile, true)); for (i = 0; i < pProfile->m_NoLines; i++) { @@ -1799,12 +1799,12 @@ static sal_Bool storeProfile(osl_TProfileImpl* pProfile, sal_Bool bCleanup) if ( ! writeProfileImpl(pTmpFile) ) { - if ( pTmpFile->m_pWriteBuf != 0 ) + if ( pTmpFile->m_pWriteBuf != nullptr ) { free(pTmpFile->m_pWriteBuf); } - pTmpFile->m_pWriteBuf=0; + pTmpFile->m_pWriteBuf=nullptr; pTmpFile->m_nWriteBufLen=0; pTmpFile->m_nWriteBufFree=0; @@ -1813,7 +1813,7 @@ static sal_Bool storeProfile(osl_TProfileImpl* pProfile, sal_Bool bCleanup) #endif closeFileImpl(pTmpFile); - return sal_False; + return false; } pProfile->m_Flags &= ~FLG_MODIFIED; @@ -1833,14 +1833,14 @@ static sal_Bool storeProfile(osl_TProfileImpl* pProfile, sal_Bool bCleanup) removeLine(pProfile, pProfile->m_NoLines - 1); free(pProfile->m_Lines); - pProfile->m_Lines = NULL; + pProfile->m_Lines = nullptr; pProfile->m_MaxLines = 0; while (pProfile->m_NoSections > 0) removeSection(pProfile, &pProfile->m_Sections[pProfile->m_NoSections - 1]); free(pProfile->m_Sections); - pProfile->m_Sections = NULL; + pProfile->m_Sections = nullptr; pProfile->m_MaxSections = 0; } } @@ -1848,14 +1848,14 @@ static sal_Bool storeProfile(osl_TProfileImpl* pProfile, sal_Bool bCleanup) #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out storeProfile [ok]"); #endif - return sal_True; + return true; } static osl_TFile* osl_openTmpProfileImpl(osl_TProfileImpl* pProfile) { - osl_TFile* pFile=0; - rtl_uString* ustrExtension=0; - rtl_uString* ustrTmpName=0; + osl_TFile* pFile=nullptr; + rtl_uString* ustrExtension=nullptr; + rtl_uString* ustrTmpName=nullptr; oslProfileOption PFlags=0; rtl_uString_newFromAscii(&ustrExtension,"tmp"); @@ -1864,9 +1864,9 @@ static osl_TFile* osl_openTmpProfileImpl(osl_TProfileImpl* pProfile) ustrTmpName=osl_ProfileGenerateExtension(pProfile->m_strFileName,ustrExtension); rtl_uString_release(ustrExtension); - if ( ustrTmpName == 0 ) + if ( ustrTmpName == nullptr ) { - return 0; + return nullptr; } if ( ! ( pProfile->m_Flags & osl_Profile_READLOCK ) ) @@ -1881,32 +1881,32 @@ static osl_TFile* osl_openTmpProfileImpl(osl_TProfileImpl* pProfile) return pFile; } -static sal_Bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile) +static bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile) { - sal_Bool bRet = sal_False; + bool bRet = false; - rtl_uString* ustrBakFile=0; - rtl_uString* ustrTmpFile=0; - rtl_uString* ustrIniFile=0; - rtl_uString* ustrExtension=0; + rtl_uString* ustrBakFile=nullptr; + rtl_uString* ustrTmpFile=nullptr; + rtl_uString* ustrIniFile=nullptr; + rtl_uString* ustrExtension=nullptr; rtl_uString_newFromAscii(&ustrExtension,"bak"); ustrBakFile=osl_ProfileGenerateExtension(pProfile->m_strFileName,ustrExtension); rtl_uString_release(ustrExtension); - ustrExtension=0; + ustrExtension=nullptr; rtl_uString_newFromAscii(&ustrExtension,"ini"); ustrIniFile=osl_ProfileGenerateExtension(pProfile->m_strFileName,ustrExtension); rtl_uString_release(ustrExtension); - ustrExtension=0; + ustrExtension=nullptr; rtl_uString_newFromAscii(&ustrExtension,"tmp"); ustrTmpFile=osl_ProfileGenerateExtension(pProfile->m_strFileName,ustrExtension); rtl_uString_release(ustrExtension); - ustrExtension=0; + ustrExtension=nullptr; /* unlink bak */ DeleteFileW( reinterpret_cast(rtl_uString_getStr( ustrBakFile )) ); @@ -1922,8 +1922,8 @@ static sal_Bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile) static rtl_uString* osl_ProfileGenerateExtension(rtl_uString* ustrFileName, rtl_uString* ustrExtension) { - rtl_uString* ustrNewFileName = 0; - rtl_uString* ustrOldExtension = 0; + rtl_uString* ustrNewFileName = nullptr; + rtl_uString* ustrOldExtension = nullptr; sal_Unicode* pFileNameBuf = rtl_uString_getStr(ustrFileName); @@ -1942,9 +1942,9 @@ static rtl_uString* osl_ProfileGenerateExtension(rtl_uString* ustrFileName, rtl_ return ustrNewFileName; } -static osl_TProfileImpl* acquireProfile(oslProfile Profile, sal_Bool bWriteable) +static osl_TProfileImpl* acquireProfile(oslProfile Profile, bool bWriteable) { - osl_TProfileImpl* pProfile = (osl_TProfileImpl*)Profile; + osl_TProfileImpl* pProfile = static_cast(Profile); oslProfileOption PFlags=0; if ( bWriteable ) @@ -1956,13 +1956,13 @@ static osl_TProfileImpl* acquireProfile(oslProfile Profile, sal_Bool bWriteable) PFlags = osl_Profile_DEFAULT; } - if (pProfile == NULL) + if (pProfile == nullptr) { #ifdef DEBUG_OSL_PROFILE OSL_TRACE("AUTOOPEN MODE"); #endif - if ( ( pProfile = (osl_TProfileImpl*)osl_openProfile( NULL, PFlags ) ) != NULL ) + if ( ( pProfile = static_cast(osl_openProfile( nullptr, PFlags )) ) != nullptr ) { pProfile->m_Flags |= FLG_AUTOOPEN; } @@ -1985,7 +1985,7 @@ static osl_TProfileImpl* acquireProfile(oslProfile Profile, sal_Bool bWriteable) pProfile->m_pFile = openFileImpl( pProfile->m_strFileName, pProfile->m_Flags | PFlags); if (!pProfile->m_pFile) - return NULL; + return nullptr; Stamp = getFileStamp(pProfile->m_pFile); @@ -2005,7 +2005,7 @@ static osl_TProfileImpl* acquireProfile(oslProfile Profile, sal_Bool bWriteable) /* A readlock file could not be written */ if ((pProfile->m_Flags & osl_Profile_READLOCK) && bWriteable) { - return NULL; + return nullptr; } } } @@ -2014,18 +2014,18 @@ static osl_TProfileImpl* acquireProfile(oslProfile Profile, sal_Bool bWriteable) return pProfile; } -static sal_Bool releaseProfile(osl_TProfileImpl* pProfile) +static bool releaseProfile(osl_TProfileImpl* pProfile) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("In releaseProfile"); #endif - if ( pProfile == 0 ) + if ( pProfile == nullptr ) { #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out releaseProfile [profile==0]"); #endif - return sal_False; + return false; } if (! (pProfile->m_Flags & osl_Profile_SYSTEM)) @@ -2035,7 +2035,7 @@ static sal_Bool releaseProfile(osl_TProfileImpl* pProfile) #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out releaseProfile [AUTOOPEN]"); #endif - return osl_closeProfile((oslProfile)pProfile); + return osl_closeProfile(static_cast(pProfile)); } else { @@ -2046,10 +2046,10 @@ static sal_Bool releaseProfile(osl_TProfileImpl* pProfile) osl_Profile_WRITELOCK | osl_Profile_FLUSHWRITE))) { if (pProfile->m_Flags & FLG_MODIFIED) - storeProfile(pProfile, sal_False); + storeProfile(pProfile, false); closeFileImpl(pProfile->m_pFile); - pProfile->m_pFile = NULL; + pProfile->m_pFile = nullptr; } } } @@ -2057,10 +2057,10 @@ static sal_Bool releaseProfile(osl_TProfileImpl* pProfile) #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out releaseProfile [ok]"); #endif - return sal_True; + return true; } -static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile, sal_Unicode *strProfile) +static bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile, sal_Unicode *strProfile) { sal_Char *pChr; sal_Char Buffer[4096] = ""; @@ -2079,7 +2079,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str while ((strPath[i] != L'"') && (strPath[i] != L'\0')) i++; - WideCharToMultiByte(CP_ACP,0, reinterpret_cast(strPath), i, Product, sizeof(Product), NULL, NULL); + WideCharToMultiByte(CP_ACP,0, reinterpret_cast(strPath), i, Product, sizeof(Product), nullptr, nullptr); Product[i] = '\0'; strPath += i; @@ -2097,10 +2097,10 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str /* if we have not product identfication, do a special handling for soffice.ini */ if (rtl_ustr_ascii_compare(strFile, SVERSION_PROFILE) == 0) { - rtl_uString * strSVProfile = NULL; - rtl_uString * strSVFallback = NULL; - rtl_uString * strSVLocation = NULL; - rtl_uString * strSVName = NULL; + rtl_uString * strSVProfile = nullptr; + rtl_uString * strSVFallback = nullptr; + rtl_uString * strSVLocation = nullptr; + rtl_uString * strSVName = nullptr; ::osl::LongPathBuffer< sal_Char > aDir( MAX_LONG_PATH ); oslProfile hProfile; @@ -2139,7 +2139,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str osl_closeProfile(hProfile); } rtl_uString_release(strSVProfile); - strSVProfile = NULL; + strSVProfile = nullptr; } /* open sversion.ini in the users directory, and try to locate the entry @@ -2180,7 +2180,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str rtl_uString_release(strSVName); /* remove any trailing build number */ - if ((pChr = strrchr(Product, '/')) != NULL) + if ((pChr = strrchr(Product, '/')) != nullptr) *pChr = '\0'; } } @@ -2192,7 +2192,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str for (n = 0; n < nArgs; n++) { - rtl_uString * strCommandArg = NULL; + rtl_uString * strCommandArg = nullptr; osl_getCommandArg( n, &strCommandArg ); if (((strCommandArg->buffer[0] == L'-') || (strCommandArg->buffer[0] == L'+')) && (rtl_ustr_ascii_compare_WithLength(strCommandArg->buffer, RTL_CONSTASCII_LENGTH(SVERSION_OPTION), SVERSION_OPTION))) @@ -2223,7 +2223,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str ::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH ); int nLen = 0; - if ((nLen = WideCharToMultiByte(CP_ACP,0, ::osl::mingw_reinterpret_cast(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL)) > 0) + if ((nLen = WideCharToMultiByte(CP_ACP,0, ::osl::mingw_reinterpret_cast(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), nullptr, nullptr)) > 0) { strcpy(aTmpPath + nLen, SVERSION_USER); if (access(aTmpPath, 0) >= 0) @@ -2241,19 +2241,19 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str if (dwPathLen == 0) { - rtl_uString * strExecutable = NULL; - rtl_uString * strTmp = NULL; + rtl_uString * strExecutable = nullptr; + rtl_uString * strTmp = nullptr; sal_Int32 nPos; /* try to find the file in the directory of the executable */ if (osl_getExecutableFile(&strTmp) != osl_Process_E_None) - return sal_False; + return false; /* convert to native path */ if (osl_getSystemPathFromFileURL(strTmp, &strExecutable) != osl_File_E_None) { rtl_uString_release(strTmp); - return sal_False; + return false; } rtl_uString_release(strTmp); @@ -2263,7 +2263,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str { if ((nPos = rtl_ustr_lastIndexOfChar(strExecutable->buffer, L':')) == -1) { - return sal_False; + return false; } else { @@ -2282,10 +2282,10 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str /* if we have no product identification use the executable file name */ if (*Product == 0) { - WideCharToMultiByte(CP_ACP,0, reinterpret_cast(strExecutable->buffer + nPos + 1), -1, Product, sizeof(Product), NULL, NULL); + WideCharToMultiByte(CP_ACP,0, reinterpret_cast(strExecutable->buffer + nPos + 1), -1, Product, sizeof(Product), nullptr, nullptr); /* remove extension */ - if ((pChr = strrchr(Product, '.')) != NULL) + if ((pChr = strrchr(Product, '.')) != nullptr) *pChr = '\0'; } @@ -2305,7 +2305,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str { ::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH ); - WideCharToMultiByte(CP_ACP,0, ::osl::mingw_reinterpret_cast(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL); + WideCharToMultiByte(CP_ACP,0, ::osl::mingw_reinterpret_cast(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), nullptr, nullptr); /* if file not exists, remove any specified subdirectories like "bin" or "program" */ @@ -2354,14 +2354,14 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str { ::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH ); - WideCharToMultiByte(CP_ACP,0, ::osl::mingw_reinterpret_cast(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL); + WideCharToMultiByte(CP_ACP,0, ::osl::mingw_reinterpret_cast(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), nullptr, nullptr); if ((access(aTmpPath, 0) < 0) && (Product[0] != '\0')) { - rtl_uString * strSVFallback = NULL; - rtl_uString * strSVProfile = NULL; - rtl_uString * strSVLocation = NULL; - rtl_uString * strSVName = NULL; + rtl_uString * strSVFallback = nullptr; + rtl_uString * strSVProfile = nullptr; + rtl_uString * strSVLocation = nullptr; + rtl_uString * strSVName = nullptr; oslProfile hProfile; rtl_uString_newFromAscii(&strSVFallback, SVERSION_FALLBACK); @@ -2425,7 +2425,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str if ((n = WideCharToMultiByte( CP_ACP,0, ::osl::mingw_reinterpret_cast(aPath), -1, aTmpPath2, - aTmpPath2.getBufSizeInSymbols(), NULL, NULL)) + aTmpPath2.getBufSizeInSymbols(), nullptr, nullptr)) > 0) { strcpy(aTmpPath2 + n, SVERSION_USER); @@ -2456,7 +2456,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str /* copy filename */ copy_ustr_n(strProfile, aPath, dwPathLen+1); - return sal_True; + return true; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/salinit.cxx b/sal/osl/w32/salinit.cxx index 141cc2fe5b3e..8122fbb18697 100644 --- a/sal/osl/w32/salinit.cxx +++ b/sal/osl/w32/salinit.cxx @@ -20,15 +20,14 @@ #include "sal/config.h" #include "system.h" +#include + #include #include #include extern "C" { -//From time.c -void sal_initGlobalTimer(); - // Prototypes for initialization and deinitialization of SAL library void sal_detail_initialize(int argc, char ** argv) @@ -45,7 +44,7 @@ void sal_detail_initialize(int argc, char ** argv) // SetSearchPathMode( // BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT); HMODULE h = GetModuleHandleW(L"kernel32.dll"); - if (h != 0) { + if (h != nullptr) { FARPROC p; #ifndef _WIN64 p = GetProcAddress(h, "SetProcessDEPPolicy"); @@ -54,11 +53,11 @@ void sal_detail_initialize(int argc, char ** argv) } #endif p = GetProcAddress(h, "SetDllDirectoryW"); - if (p != 0) { + if (p != nullptr) { reinterpret_cast< BOOL (WINAPI *)(LPCWSTR) >(p)(L""); } p = GetProcAddress(h, "SetSearchPathMode"); - if (p != 0) { + if (p != nullptr) { reinterpret_cast< BOOL (WINAPI *)(DWORD) >(p)(0x8001); } } diff --git a/sal/osl/w32/secimpl.h b/sal/osl/w32/secimpl.h index a6daf7dbedce..de8a5069ee03 100644 --- a/sal/osl/w32/secimpl.h +++ b/sal/osl/w32/secimpl.h @@ -17,8 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef _OSL_SECURITYIMPL_H_ -#define _OSL_SECURITYIMPL_H_ +#ifndef INCLUDED_SAL_OSL_W32_SECIMPL_H +#define INCLUDED_SAL_OSL_W32_SECIMPL_H #include @@ -30,7 +30,7 @@ extern "C" { #endif -typedef struct _oslSecurityImpl { +typedef struct { HANDLE m_hProfile; HANDLE m_hToken; sal_Unicode m_User[USER_BUFFER_SIZE]; diff --git a/sal/osl/w32/security.c b/sal/osl/w32/security.c index 1d31eeffd9ba..d4dad55ade84 100644 --- a/sal/osl/w32/security.c +++ b/sal/osl/w32/security.c @@ -35,7 +35,7 @@ /* Declarations based on USERENV.H for Windows 2000 Beta 2 */ #define PI_NOUI 0x00000001 // Prevents displaying of messages -typedef struct _PROFILEINFOW { +typedef struct { DWORD dwSize; // Must be set to sizeof(PROFILEINFO) DWORD dwFlags; // See flags above LPWSTR lpUserName; // User name (required) @@ -548,7 +548,7 @@ sal_Bool SAL_CALL osl_loadUserProfile(oslSecurity Security) if (fLoadUserProfile && fUnloadUserProfile) { - rtl_uString *buffer = 0; + rtl_uString *buffer = NULL; PROFILEINFOW pi; getUserNameImpl(Security, &buffer, sal_False); @@ -743,7 +743,7 @@ static sal_Bool GetSpecialFolder(rtl_uString **strPath, int nFolder) if (SUCCEEDED(pSHGetMalloc(&pMalloc))) { - pMalloc->lpVtbl->Free(pMalloc, pidl); + pMalloc->lpVtbl->Free(pMalloc, (void *) pidl); pMalloc->lpVtbl->Release(pMalloc); } } @@ -782,7 +782,7 @@ static BOOL Privilege(LPTSTR strPrivilege, BOOL bEnable) /* enable or disable the privilege */ - if (!AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, 0)) + if (!AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, NULL)) return FALSE; if (!CloseHandle(hToken)) diff --git a/sal/osl/w32/signal.cxx b/sal/osl/w32/signal.cxx index 743d2b2fb8c8..a9fa84f7c86b 100644 --- a/sal/osl/w32/signal.cxx +++ b/sal/osl/w32/signal.cxx @@ -52,7 +52,7 @@ bool onInitSignal() HMODULE hFaultRep = LoadLibrary( "faultrep.dll" ); if ( hFaultRep ) { - pfn_ADDEREXCLUDEDAPPLICATIONW pfn = (pfn_ADDEREXCLUDEDAPPLICATIONW)GetProcAddress( hFaultRep, "AddERExcludedApplicationW" ); + pfn_ADDEREXCLUDEDAPPLICATIONW pfn = reinterpret_cast(GetProcAddress( hFaultRep, "AddERExcludedApplicationW" )); if ( pfn ) pfn( L"SOFFICE.EXE" ); FreeLibrary( hFaultRep ); diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx index ea6ea0df3bc0..c927f4231a08 100644 --- a/sal/osl/w32/socket.cxx +++ b/sal/osl/w32/socket.cxx @@ -264,25 +264,19 @@ static oslSocketError osl_SocketErrorFromNative(int nativeType) /*****************************************************************************/ /* oslSocketDialupImpl */ /*****************************************************************************/ -static oslSocketDialupImpl *pDialupImpl = NULL; +static oslSocketDialupImpl *pDialupImpl = nullptr; -/* - * __osl_createSocketDialupImpl. - */ -static oslSocketDialupImpl* __osl_createSocketDialupImpl() +static oslSocketDialupImpl* osl_createSocketDialupImpl() { oslSocketDialupImpl *pImpl; - pImpl = (oslSocketDialupImpl*)rtl_allocateZeroMemory( sizeof (oslSocketDialupImpl)); + pImpl = static_cast(rtl_allocateZeroMemory( sizeof (oslSocketDialupImpl))); InitializeCriticalSection (&pImpl->m_hMutex); return (pImpl); } -/* - * __osl_initSocketDialupImpl. - */ -static void __osl_initSocketDialupImpl (oslSocketDialupImpl *pImpl) +static void osl_initSocketDialupImpl (oslSocketDialupImpl *pImpl) { #ifdef SOCKET_USE_AUTODIAL if (pImpl) @@ -312,10 +306,7 @@ static void __osl_initSocketDialupImpl (oslSocketDialupImpl *pImpl) #endif } -/* - * __osl_destroySocketDialupImpl. - */ -static void __osl_destroySocketDialupImpl (oslSocketDialupImpl *pImpl) +static void osl_destroySocketDialupImpl (oslSocketDialupImpl *pImpl) { if (pImpl) { @@ -340,27 +331,24 @@ static void __osl_destroySocketDialupImpl (oslSocketDialupImpl *pImpl) } } -/* - * __osl_querySocketDialupImpl. - */ -static sal_Bool __osl_querySocketDialupImpl() +static bool osl_querySocketDialupImpl() { - sal_Bool result; + bool result; - if (pDialupImpl == NULL) + if (pDialupImpl == nullptr) { - pDialupImpl = __osl_createSocketDialupImpl(); - __osl_initSocketDialupImpl (pDialupImpl); + pDialupImpl = osl_createSocketDialupImpl(); + osl_initSocketDialupImpl (pDialupImpl); } EnterCriticalSection (&pDialupImpl->m_hMutex); - result = sal_True; + result = true; if (pDialupImpl->m_pfnGetConnectedState) { DWORD dwFlags = 0; - result = (sal_Bool)(pDialupImpl->m_pfnGetConnectedState)(&dwFlags, 0); + result = (pDialupImpl->m_pfnGetConnectedState)(&dwFlags, 0); pDialupImpl->m_dwFlags |= dwFlags; } @@ -368,28 +356,25 @@ static sal_Bool __osl_querySocketDialupImpl() return result; } -/* - * __osl_attemptSocketDialupImpl. - */ -static sal_Bool __osl_attemptSocketDialupImpl() +static bool osl_attemptSocketDialupImpl() { - sal_Bool result; + bool result; - if (pDialupImpl == NULL) + if (pDialupImpl == nullptr) { - pDialupImpl = __osl_createSocketDialupImpl(); - __osl_initSocketDialupImpl (pDialupImpl); + pDialupImpl = osl_createSocketDialupImpl(); + osl_initSocketDialupImpl (pDialupImpl); } EnterCriticalSection (&pDialupImpl->m_hMutex); - result = __osl_querySocketDialupImpl(); + result = osl_querySocketDialupImpl(); if (!result) { - result = sal_True; + result = true; if (pDialupImpl->m_pfnAutodial) { - result = (sal_Bool)(pDialupImpl->m_pfnAutodial)(0, 0); + result = (pDialupImpl->m_pfnAutodial)(0, 0); if (result) pDialupImpl->m_dwFlags |= INTERNET_CONNECTION_HANGUP; else @@ -419,12 +404,9 @@ struct LeakWarning LeakWarning socketWarning; #endif -/* - * __osl_createSocketImpl. - */ -oslSocket __osl_createSocketImpl(SOCKET Socket) +oslSocket osl_createSocketImpl_(SOCKET Socket) { - oslSocket pSockImpl = (oslSocket) rtl_allocateZeroMemory( sizeof(struct oslSocketImpl)); + oslSocket pSockImpl = static_cast(rtl_allocateZeroMemory( sizeof(struct oslSocketImpl))); pSockImpl->m_Socket = Socket; pSockImpl->m_nRefCount = 1; @@ -433,25 +415,22 @@ oslSocket __osl_createSocketImpl(SOCKET Socket) return (pSockImpl); } -/* - * __osl_destroySocketImpl. - */ -void __osl_destroySocketImpl(oslSocketImpl *pImpl) +void osl_destroySocketImpl_(oslSocketImpl *pImpl) { if (pImpl) { if (--g_nSocketImpl == 0) { - __osl_destroySocketDialupImpl (pDialupImpl); - pDialupImpl = NULL; + osl_destroySocketDialupImpl (pDialupImpl); + pDialupImpl = nullptr; } rtl_freeMemory (pImpl); } } /*****************************************************************************/ -static oslSocketAddr __osl_createSocketAddr( ) +static oslSocketAddr osl_createSocketAddr_( ) { - oslSocketAddr pAddr = (oslSocketAddr) rtl_allocateZeroMemory( sizeof( struct oslSocketAddrImpl )); + oslSocketAddr pAddr = static_cast(rtl_allocateZeroMemory( sizeof( struct oslSocketAddrImpl ))); pAddr->m_nRefCount = 1; #if OSL_DEBUG_LEVEL > 0 g_nSocketAddr ++; @@ -459,17 +438,17 @@ static oslSocketAddr __osl_createSocketAddr( ) return pAddr; } -static oslSocketAddr __osl_createSocketAddrWithFamily( +static oslSocketAddr osl_createSocketAddrWithFamily_( oslAddrFamily family, sal_Int32 port, sal_uInt32 nAddr ) { OSL_ASSERT( family == osl_Socket_FamilyInet ); - oslSocketAddr pAddr = __osl_createSocketAddr(); + oslSocketAddr pAddr = osl_createSocketAddr_(); switch( family ) { case osl_Socket_FamilyInet: { - struct sockaddr_in* pInetAddr= (struct sockaddr_in*)&(pAddr->m_sockaddr); + struct sockaddr_in* pInetAddr= reinterpret_cast(&pAddr->m_sockaddr); pInetAddr->sin_family = FAMILY_TO_NATIVE(osl_Socket_FamilyInet); pInetAddr->sin_addr.s_addr = nAddr; @@ -482,14 +461,14 @@ static oslSocketAddr __osl_createSocketAddrWithFamily( return pAddr; } -static oslSocketAddr __osl_createSocketAddrFromSystem( struct sockaddr *pSystemSockAddr ) +static oslSocketAddr osl_createSocketAddrFromSystem_( struct sockaddr *pSystemSockAddr ) { - oslSocketAddr pAddr = __osl_createSocketAddr(); + oslSocketAddr pAddr = osl_createSocketAddr_(); memcpy( &(pAddr->m_sockaddr), pSystemSockAddr, sizeof( sockaddr ) ); return pAddr; } -static void __osl_destroySocketAddr( oslSocketAddr addr ) +static void osl_destroySocketAddr_( oslSocketAddr addr ) { #if OSL_DEBUG_LEVEL > 0 g_nSocketAddr --; @@ -501,16 +480,16 @@ static void __osl_destroySocketAddr( oslSocketAddr addr ) /*****************************************************************************/ oslSocketAddr SAL_CALL osl_createEmptySocketAddr(oslAddrFamily Family) { - oslSocketAddr pAddr = 0; + oslSocketAddr pAddr = nullptr; /* is it an internet-Addr? */ if (Family == osl_Socket_FamilyInet) { - pAddr = __osl_createSocketAddrWithFamily(Family, 0 , htonl(INADDR_ANY) ); + pAddr = osl_createSocketAddrWithFamily_(Family, 0 , htonl(INADDR_ANY) ); } else { - pAddr = __osl_createSocketAddrWithFamily( Family , 0 , 0 ); + pAddr = osl_createSocketAddrWithFamily_( Family , 0 , 0 ); } return pAddr; @@ -522,10 +501,10 @@ oslSocketAddr SAL_CALL osl_createEmptySocketAddr(oslAddrFamily Family) // @deprecated, to be removed oslSocketAddr SAL_CALL osl_copySocketAddr(oslSocketAddr Addr) { - oslSocketAddr pCopy = 0; + oslSocketAddr pCopy = nullptr; if (Addr) { - pCopy = __osl_createSocketAddr(); + pCopy = osl_createSocketAddr_(); if (pCopy) memcpy(&(pCopy->m_sockaddr),&(Addr->m_sockaddr), sizeof(struct sockaddr)); @@ -552,13 +531,13 @@ sal_Bool SAL_CALL osl_isEqualSocketAddr(oslSocketAddr Addr1, oslSocketAddr Addr2 { case AF_INET: { - struct sockaddr_in* pInetAddr1= (struct sockaddr_in*)pAddr1; - struct sockaddr_in* pInetAddr2= (struct sockaddr_in*)pAddr2; + struct sockaddr_in* pInetAddr1= reinterpret_cast(pAddr1); + struct sockaddr_in* pInetAddr2= reinterpret_cast(pAddr2); if ((pInetAddr1->sin_family == pInetAddr2->sin_family) && (pInetAddr1->sin_addr.s_addr == pInetAddr2->sin_addr.s_addr) && (pInetAddr1->sin_port == pInetAddr2->sin_port)) - return sal_True; + return true; SAL_FALLTHROUGH; } @@ -569,7 +548,7 @@ sal_Bool SAL_CALL osl_isEqualSocketAddr(oslSocketAddr Addr1, oslSocketAddr Addr2 } } - return sal_False; + return false; } /*****************************************************************************/ @@ -627,13 +606,13 @@ oslSocketAddr SAL_CALL osl_createInetBroadcastAddr ( else { /* No broadcast in class D */ - return ((oslSocketAddr)NULL); + return nullptr; } nAddr = htonl(nAddr); } oslSocketAddr pAddr = - __osl_createSocketAddrWithFamily( osl_Socket_FamilyInet, htons( (sal_uInt16) Port), nAddr ); + osl_createSocketAddrWithFamily_( osl_Socket_FamilyInet, htons( (sal_uInt16) Port), nAddr ); return pAddr; } @@ -662,10 +641,10 @@ oslSocketAddr SAL_CALL osl_createInetSocketAddr ( rtl_string_release (pDottedAddr); #endif - oslSocketAddr pAddr = 0; + oslSocketAddr pAddr = nullptr; if(Addr != OSL_INADDR_NONE) { - pAddr = __osl_createSocketAddrWithFamily( osl_Socket_FamilyInet, htons( (sal_uInt16)Port), Addr ); + pAddr = osl_createSocketAddrWithFamily_( osl_Socket_FamilyInet, htons( (sal_uInt16)Port), Addr ); } return pAddr; } @@ -680,7 +659,7 @@ oslSocketResult SAL_CALL osl_setAddrOfSocketAddr( oslSocketAddr pAddr, sal_Seque { OSL_ASSERT( pAddr->m_sockaddr.sa_family == FAMILY_TO_NATIVE( osl_Socket_FamilyInet ) ); OSL_ASSERT( pByteSeq->nElements == 4 ); - struct sockaddr_in * pSystemInetAddr = (struct sockaddr_in * ) &(pAddr->m_sockaddr); + struct sockaddr_in * pSystemInetAddr = reinterpret_cast(&pAddr->m_sockaddr); memcpy( &(pSystemInetAddr->sin_addr) , pByteSeq->elements , 4 ); res = osl_Socket_Ok; } @@ -698,8 +677,8 @@ oslSocketResult SAL_CALL osl_getAddrOfSocketAddr( oslSocketAddr pAddr, sal_Seque oslSocketResult res = osl_Socket_Error; if( pAddr && ppByteSeq ) { - struct sockaddr_in * pSystemInetAddr = (struct sockaddr_in * ) &(pAddr->m_sockaddr); - rtl_byte_sequence_constructFromArray( ppByteSeq , (sal_Int8 *) &(pSystemInetAddr->sin_addr),4); + struct sockaddr_in * pSystemInetAddr = reinterpret_cast(&pAddr->m_sockaddr); + rtl_byte_sequence_constructFromArray( ppByteSeq , reinterpret_cast(&pSystemInetAddr->sin_addr),4); res = osl_Socket_Ok; } return res; @@ -729,7 +708,7 @@ static oslHostAddr __osl_hostentToHostAddr (const struct hostent *he) RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); OSL_ASSERT(cn != 0); - pSocketAddr = __osl_createSocketAddr(); + pSocketAddr = osl_createSocketAddr_(); if (pSocketAddr == NULL) { @@ -754,7 +733,7 @@ static oslHostAddr __osl_hostentToHostAddr (const struct hostent *he) OSL_TRACE("_osl_hostentToHostAddr(): unknown address family."); OSL_ASSERT(sal_False); - __osl_destroySocketAddr( pSocketAddr ); + osl_destroySocketAddr_( pSocketAddr ); rtl_uString_release(cn); return ((oslHostAddr)NULL); } @@ -763,7 +742,7 @@ static oslHostAddr __osl_hostentToHostAddr (const struct hostent *he) if (pAddr == NULL) { - __osl_destroySocketAddr( pSocketAddr ); + osl_destroySocketAddr_( pSocketAddr ); rtl_uString_release(cn); return ((oslHostAddr)NULL); } @@ -783,31 +762,31 @@ oslHostAddr SAL_CALL osl_createHostAddr ( const oslSocketAddr pSocketAddr) { oslHostAddr pAddr; - rtl_uString *cn= NULL; + rtl_uString *cn= nullptr; - if ((strHostname == NULL) || (strHostname->length == 0) || (pSocketAddr == NULL)) - return ((oslHostAddr)NULL); + if ((strHostname == nullptr) || (strHostname->length == 0) || (pSocketAddr == nullptr)) + return nullptr; rtl_uString_newFromString( &cn, strHostname); if ( ! pSocketAddr ) { rtl_uString_release(cn); - return ((oslHostAddr)NULL); + return nullptr; } - pAddr= (oslHostAddr)rtl_allocateMemory (sizeof (struct oslHostAddrImpl)); + pAddr= static_cast(rtl_allocateMemory (sizeof (struct oslHostAddrImpl))); - if (pAddr == NULL) + if (pAddr == nullptr) { rtl_uString_release(cn); - return ((oslHostAddr)NULL); + return nullptr; } pAddr->pHostName= cn; pAddr->pSockAddr= osl_copySocketAddr( pSocketAddr ); - return ((oslHostAddr)pAddr); + return pAddr; } /*****************************************************************************/ @@ -815,10 +794,10 @@ oslHostAddr SAL_CALL osl_createHostAddr ( /*****************************************************************************/ oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *strHostname) { - if ((strHostname == NULL) || (strHostname->length == 0)) - return ((oslHostAddr)NULL); + if ((strHostname == nullptr) || (strHostname->length == 0)) + return nullptr; - if (__osl_attemptSocketDialupImpl()) + if (osl_attemptSocketDialupImpl()) { #if _WIN32_WINNT < _WIN32_WINNT_VISTA struct hostent *he; @@ -846,7 +825,7 @@ oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *strHostname) pRet = static_cast( rtl_allocateZeroMemory(sizeof(struct oslHostAddrImpl))); rtl_uString_newFromStr(&pRet->pHostName, pIter->ai_canonname); - pRet->pSockAddr = __osl_createSocketAddr(); + pRet->pSockAddr = osl_createSocketAddr_(); memcpy(& pRet->pSockAddr->m_sockaddr, pIter->ai_addr, pIter->ai_addrlen); break; // ignore other results @@ -861,7 +840,7 @@ oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *strHostname) } #endif // _WIN32_WINNT } - return ((oslHostAddr)NULL); + return nullptr; } /*****************************************************************************/ @@ -869,17 +848,17 @@ oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *strHostname) /*****************************************************************************/ oslHostAddr SAL_CALL osl_createHostAddrByAddr(const oslSocketAddr pAddr) { - if (pAddr == NULL) - return ((oslHostAddr)NULL); + if (pAddr == nullptr) + return nullptr; if (pAddr->m_sockaddr.sa_family == FAMILY_TO_NATIVE(osl_Socket_FamilyInet)) { - const struct sockaddr_in *sin= (const struct sockaddr_in *)&(pAddr->m_sockaddr); + const struct sockaddr_in *sin= reinterpret_cast(&pAddr->m_sockaddr); if (sin->sin_addr.s_addr == htonl(INADDR_ANY)) - return ((oslHostAddr)NULL); + return nullptr; - if (__osl_attemptSocketDialupImpl()) + if (osl_attemptSocketDialupImpl()) { #if _WIN32_WINNT < _WIN32_WINNT_VISTA struct hostent *he; @@ -899,7 +878,7 @@ oslHostAddr SAL_CALL osl_createHostAddrByAddr(const oslSocketAddr pAddr) rtl_allocateZeroMemory(sizeof(struct oslHostAddrImpl))); rtl_uString_newFromStr(&pRet->pHostName, reinterpret_cast(&buf)); - pRet->pSockAddr = __osl_createSocketAddr(); + pRet->pSockAddr = osl_createSocketAddr_(); memcpy(& pRet->pSockAddr->m_sockaddr, & pAddr->m_sockaddr, sizeof(struct sockaddr)); return pRet; @@ -912,7 +891,7 @@ oslHostAddr SAL_CALL osl_createHostAddrByAddr(const oslSocketAddr pAddr) } } - return ((oslHostAddr)NULL); + return nullptr; } /*****************************************************************************/ @@ -920,12 +899,12 @@ oslHostAddr SAL_CALL osl_createHostAddrByAddr(const oslSocketAddr pAddr) /*****************************************************************************/ oslHostAddr SAL_CALL osl_copyHostAddr(const oslHostAddr Addr) { - oslHostAddr pAddr= (oslHostAddr)Addr; + oslHostAddr pAddr = Addr; if (pAddr) return osl_createHostAddr (pAddr->pHostName, pAddr->pSockAddr); else - return ((oslHostAddr)NULL); + return nullptr; } /*****************************************************************************/ @@ -946,9 +925,9 @@ void SAL_CALL osl_getHostnameOfHostAddr( oslSocketAddr SAL_CALL osl_getSocketAddrOfHostAddr(const oslHostAddr pAddr) { if (pAddr) - return (const oslSocketAddr)(pAddr->pSockAddr); + return pAddr->pSockAddr; else - return NULL; + return nullptr; } /*****************************************************************************/ @@ -980,15 +959,15 @@ oslSocketResult SAL_CALL osl_getLocalHostname (rtl_uString **strLocalHostname) if (gethostname(Host, sizeof(Host)) == 0) { /* check if we have an FQDN */ - if (strchr(Host, '.') == NULL) + if (strchr(Host, '.') == nullptr) { oslHostAddr pAddr; - rtl_uString *hostName= NULL; + rtl_uString *hostName= nullptr; rtl_string2UString( &hostName, Host, strlen(Host), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); - OSL_ASSERT(hostName != 0); + OSL_ASSERT(hostName != nullptr); /* no, determine it via dns */ pAddr = osl_createHostAddrByName(hostName); @@ -999,7 +978,7 @@ oslSocketResult SAL_CALL osl_getLocalHostname (rtl_uString **strLocalHostname) else memset(LocalHostname, 0, sizeof(LocalHostname)); - osl_destroyHostAddr ((oslHostAddr)pAddr); + osl_destroyHostAddr (pAddr); } } } @@ -1018,15 +997,14 @@ oslSocketResult SAL_CALL osl_getLocalHostname (rtl_uString **strLocalHostname) /*****************************************************************************/ oslSocketAddr SAL_CALL osl_resolveHostname(rtl_uString* strHostname) { - oslHostAddr pAddr= - (oslHostAddr )osl_createHostAddrByName (strHostname); + oslHostAddr pAddr = osl_createHostAddrByName (strHostname); if (pAddr) { oslSocketAddr SockAddr = osl_copySocketAddr( pAddr->pSockAddr ); osl_destroyHostAddr(pAddr); return (SockAddr); } - return ((oslSocketAddr)NULL); + return nullptr; } /*****************************************************************************/ @@ -1038,8 +1016,8 @@ sal_Int32 SAL_CALL osl_getServicePort ( { struct servent* ps; - rtl_String *str_Servicename=NULL; - rtl_String *str_Protocol=NULL; + rtl_String *str_Servicename=nullptr; + rtl_String *str_Protocol=nullptr; rtl_uString2String( &str_Servicename, @@ -1059,7 +1037,7 @@ sal_Int32 SAL_CALL osl_getServicePort ( rtl_string_release( str_Servicename ); rtl_string_release( str_Protocol ); - if (ps != 0) + if (ps != nullptr) return ntohs(ps->s_port); return OSL_INVALID_PORT; @@ -1070,7 +1048,7 @@ sal_Int32 SAL_CALL osl_getServicePort ( /*****************************************************************************/ void SAL_CALL osl_destroySocketAddr(oslSocketAddr pAddr) { - __osl_destroySocketAddr( pAddr ); + osl_destroySocketAddr_( pAddr ); } /*****************************************************************************/ @@ -1091,7 +1069,7 @@ sal_Int32 SAL_CALL osl_getInetPortOfSocketAddr(oslSocketAddr pAddr) { if( pAddr ) { - struct sockaddr_in* pSystemInetAddr= (struct sockaddr_in*)&(pAddr->m_sockaddr); + struct sockaddr_in* pSystemInetAddr= reinterpret_cast(&pAddr->m_sockaddr); if (pSystemInetAddr->sin_family == FAMILY_TO_NATIVE(osl_Socket_FamilyInet)) return ntohs(pSystemInetAddr->sin_port); @@ -1106,16 +1084,16 @@ sal_Bool SAL_CALL osl_setInetPortOfSocketAddr ( oslSocketAddr pAddr, sal_Int32 Port) { - if (pAddr == NULL) - return sal_False; + if (pAddr == nullptr) + return false; - struct sockaddr_in* pSystemInetAddr= (struct sockaddr_in*)&(pAddr->m_sockaddr); + struct sockaddr_in* pSystemInetAddr= reinterpret_cast(&pAddr->m_sockaddr); if (pSystemInetAddr->sin_family != FAMILY_TO_NATIVE(osl_Socket_FamilyInet)) - return sal_False; + return false; pSystemInetAddr->sin_port= htons((short)Port); - return sal_True; + return true; } /*****************************************************************************/ @@ -1146,14 +1124,14 @@ oslSocketResult SAL_CALL osl_getDottedInetAddrOfSocketAddr ( oslSocketAddr pAddr, rtl_uString **strDottedInetAddr) { - if (pAddr == NULL) + if (pAddr == nullptr) return osl_Socket_Error; - struct sockaddr_in *pSystemInetAddr = (struct sockaddr_in*) &(pAddr->m_sockaddr); + struct sockaddr_in *pSystemInetAddr = reinterpret_cast(&pAddr->m_sockaddr); if (pSystemInetAddr->sin_family != FAMILY_TO_NATIVE(osl_Socket_FamilyInet)) return osl_Socket_Error; - *strDottedInetAddr = 0; + *strDottedInetAddr = nullptr; #if _WIN32_WINNT < _WIN32_WINNT_VISTA sal_Char * pDotted = inet_ntoa (pSystemInetAddr->sin_addr); rtl_string2UString( @@ -1171,7 +1149,7 @@ oslSocketResult SAL_CALL osl_getDottedInetAddrOfSocketAddr ( } rtl_uString_newFromStr(strDottedInetAddr, ret); #endif // _WIN32_WINNT - OSL_ASSERT(*strDottedInetAddr != 0); + OSL_ASSERT(*strDottedInetAddr != nullptr); return osl_Socket_Ok; } @@ -1185,10 +1163,10 @@ oslSocket SAL_CALL osl_createSocket ( oslProtocol Protocol) { /* alloc memory */ - oslSocket pSocket = __osl_createSocketImpl(0); + oslSocket pSocket = osl_createSocketImpl_(0); - if (pSocket == NULL) - return 0; + if (pSocket == nullptr) + return nullptr; /* create socket */ pSocket->m_Socket= socket(FAMILY_TO_NATIVE(Family), @@ -1198,8 +1176,8 @@ oslSocket SAL_CALL osl_createSocket ( /* creation failed => free memory */ if(pSocket->m_Socket == OSL_INVALID_SOCKET) { - __osl_destroySocketImpl(pSocket); - pSocket= 0; + osl_destroySocketImpl_(pSocket); + pSocket= nullptr; } else { @@ -1219,7 +1197,7 @@ void SAL_CALL osl_releaseSocket( oslSocket pSocket ) if( pSocket && 0 == osl_atomic_decrement( &(pSocket->m_nRefCount) ) ) { osl_closeSocket( pSocket ); - __osl_destroySocketImpl( pSocket ); + osl_destroySocketImpl_( pSocket ); } } @@ -1229,7 +1207,7 @@ void SAL_CALL osl_releaseSocket( oslSocket pSocket ) void SAL_CALL osl_closeSocket(oslSocket pSocket) { /* socket already invalid */ - if(pSocket==0) + if(pSocket==nullptr) return; /* close */ @@ -1249,15 +1227,15 @@ oslSocketAddr SAL_CALL osl_getLocalAddrOfSocket(oslSocket pSocket) struct sockaddr Addr; int AddrLen; - if (pSocket == NULL) /* ENOTSOCK */ - return ((oslSocketAddr)NULL); + if (pSocket == nullptr) /* ENOTSOCK */ + return nullptr; AddrLen= sizeof(struct sockaddr); if (getsockname(pSocket->m_Socket, &Addr, &AddrLen) == OSL_SOCKET_ERROR) - return ((oslSocketAddr)NULL); + return nullptr; - oslSocketAddr pAddr = __osl_createSocketAddrFromSystem( &Addr ); + oslSocketAddr pAddr = osl_createSocketAddrFromSystem_( &Addr ); return pAddr; } @@ -1269,15 +1247,15 @@ oslSocketAddr SAL_CALL osl_getPeerAddrOfSocket(oslSocket pSocket) struct sockaddr Addr; int AddrLen; - if (pSocket == NULL) /* ENOTSOCK */ - return ((oslSocketAddr)NULL); + if (pSocket == nullptr) /* ENOTSOCK */ + return nullptr; AddrLen= sizeof(struct sockaddr); if (getpeername(pSocket->m_Socket, &Addr, &AddrLen) == OSL_SOCKET_ERROR) - return ((oslSocketAddr)NULL); + return nullptr; - oslSocketAddr pAddr = __osl_createSocketAddrFromSystem( &Addr ); + oslSocketAddr pAddr = osl_createSocketAddrFromSystem_( &Addr ); return pAddr; } @@ -1288,8 +1266,8 @@ sal_Bool SAL_CALL osl_bindAddrToSocket ( oslSocket pSocket, oslSocketAddr pAddr) { OSL_ASSERT( pAddr ); - if (pSocket == NULL) /* ENOTSOCK */ - return sal_False; + if (pSocket == nullptr) /* ENOTSOCK */ + return false; return (bind(pSocket->m_Socket, &(pAddr->m_sockaddr), @@ -1305,16 +1283,16 @@ oslSocketResult SAL_CALL osl_connectSocketTo ( const TimeValue* pTimeout) { - if (pSocket == NULL) /* ENOTSOCK */ + if (pSocket == nullptr) /* ENOTSOCK */ return osl_Socket_Error; - if (pAddr == NULL) /* EDESTADDRREQ */ + if (pAddr == nullptr) /* EDESTADDRREQ */ return osl_Socket_Error; - if (!__osl_attemptSocketDialupImpl()) /* ENETDOWN */ + if (!osl_attemptSocketDialupImpl()) /* ENETDOWN */ return osl_Socket_Error; - if (pTimeout == NULL) + if (pTimeout == nullptr) { if(connect(pSocket->m_Socket, &(pAddr->m_sockaddr), @@ -1392,9 +1370,9 @@ oslSocketResult SAL_CALL osl_connectSocketTo ( /* select */ error= select(pSocket->m_Socket+1, - 0, + nullptr, &fds, - 0, + nullptr, &tv); if (error > 0) /* connected */ @@ -1438,8 +1416,8 @@ sal_Bool SAL_CALL osl_listenOnSocket ( oslSocket pSocket, sal_Int32 MaxPendingConnections) { - if (pSocket == NULL) /* ENOTSOCK */ - return sal_False; + if (pSocket == nullptr) /* ENOTSOCK */ + return false; return (listen(pSocket->m_Socket, MaxPendingConnections == -1 ? @@ -1454,8 +1432,8 @@ oslSocket SAL_CALL osl_acceptConnectionOnSocket ( oslSocket pSocket, oslSocketAddr* ppAddr) { - if (pSocket == NULL) /* ENOTSOCK */ - return ((oslSocket)NULL); + if (pSocket == nullptr) /* ENOTSOCK */ + return nullptr; SOCKET Connection; if(ppAddr) @@ -1463,7 +1441,7 @@ oslSocket SAL_CALL osl_acceptConnectionOnSocket ( if( *ppAddr ) { osl_destroySocketAddr( *ppAddr ); - *ppAddr = 0; + *ppAddr = nullptr; } int AddrLen= sizeof(struct sockaddr); @@ -1474,23 +1452,23 @@ oslSocket SAL_CALL osl_acceptConnectionOnSocket ( OSL_ASSERT(AddrLen == sizeof(struct sockaddr)); if(Connection != static_cast(OSL_SOCKET_ERROR)) - *ppAddr= __osl_createSocketAddrFromSystem(&Addr); + *ppAddr= osl_createSocketAddrFromSystem_(&Addr); else - *ppAddr = NULL; + *ppAddr = nullptr; } else { /* user is not interested in peer-addr */ - Connection= accept(pSocket->m_Socket, 0, 0); + Connection= accept(pSocket->m_Socket, nullptr, nullptr); } /* accept failed? */ if(Connection == static_cast(OSL_SOCKET_ERROR)) - return ((oslSocket)NULL); + return nullptr; /* alloc memory */ oslSocket pConnectionSocket; - pConnectionSocket= __osl_createSocketImpl(Connection); + pConnectionSocket= osl_createSocketImpl_(Connection); pConnectionSocket->m_Flags = 0; @@ -1506,11 +1484,11 @@ sal_Int32 SAL_CALL osl_receiveSocket ( sal_uInt32 BytesToRead, oslSocketMsgFlag Flag) { - if (pSocket == NULL) /* ENOTSOCK */ + if (pSocket == nullptr) /* ENOTSOCK */ return osl_Socket_Error; return recv(pSocket->m_Socket, - (sal_Char*)pBuffer, + static_cast(pBuffer), BytesToRead, MSG_FLAG_TO_NATIVE(Flag)); } @@ -1525,7 +1503,7 @@ sal_Int32 SAL_CALL osl_receiveFromSocket ( sal_uInt32 BufferSize, oslSocketMsgFlag Flag) { - struct sockaddr *pSystemSockAddr = 0; + struct sockaddr *pSystemSockAddr = nullptr; int AddrLen = 0; if( SenderAddr ) { @@ -1533,11 +1511,11 @@ sal_Int32 SAL_CALL osl_receiveFromSocket ( pSystemSockAddr = &(SenderAddr->m_sockaddr); } - if (pSocket == NULL) /* ENOTSOCK */ + if (pSocket == nullptr) /* ENOTSOCK */ return osl_Socket_Error; return recvfrom(pSocket->m_Socket, - (sal_Char*)pBuffer, + static_cast(pBuffer), BufferSize, MSG_FLAG_TO_NATIVE(Flag), pSystemSockAddr, @@ -1553,11 +1531,11 @@ sal_Int32 SAL_CALL osl_sendSocket ( sal_uInt32 BytesToSend, oslSocketMsgFlag Flag) { - if (pSocket == NULL) /* ENOTSOCK */ + if (pSocket == nullptr) /* ENOTSOCK */ return osl_Socket_Error; return send(pSocket->m_Socket, - (sal_Char*)pBuffer, + static_cast(pBuffer), BytesToSend, MSG_FLAG_TO_NATIVE(Flag)); } @@ -1572,22 +1550,22 @@ sal_Int32 SAL_CALL osl_sendToSocket ( sal_uInt32 BytesToSend, oslSocketMsgFlag Flag) { - if (pSocket == NULL) /* ENOTSOCK */ + if (pSocket == nullptr) /* ENOTSOCK */ return osl_Socket_Error; /* ReceiverAddr might be 0 when used on a connected socket. */ /* Then sendto should behave like send. */ - struct sockaddr *pSystemSockAddr = 0; + struct sockaddr *pSystemSockAddr = nullptr; if( ReceiverAddr ) pSystemSockAddr = &(ReceiverAddr->m_sockaddr); return sendto(pSocket->m_Socket, - (sal_Char*)pBuffer, + static_cast(pBuffer), BytesToSend, MSG_FLAG_TO_NATIVE(Flag), pSystemSockAddr, - pSystemSockAddr == 0 ? 0 : sizeof(struct sockaddr)); + pSystemSockAddr == nullptr ? 0 : sizeof(struct sockaddr)); } /*****************************************************************************/ @@ -1595,7 +1573,7 @@ sal_Int32 SAL_CALL osl_sendToSocket ( /*****************************************************************************/ sal_Int32 SAL_CALL osl_readSocket( oslSocket pSocket, void *pBuffer, sal_Int32 n ) { - sal_uInt8 * Ptr = (sal_uInt8 *)pBuffer; + sal_uInt8 * Ptr = static_cast(pBuffer); OSL_ASSERT( pSocket); @@ -1634,7 +1612,7 @@ sal_Int32 SAL_CALL osl_writeSocket( oslSocket pSocket, const void *pBuffer, sal_ /* loop until all desired bytes were send or an error occurred */ sal_uInt32 BytesSend= 0; sal_uInt32 BytesToSend= n; - sal_uInt8 *Ptr = ( sal_uInt8 * )pBuffer; + sal_uInt8 const *Ptr = static_cast(pBuffer); while (BytesToSend > 0) { sal_Int32 RetVal; @@ -1665,8 +1643,8 @@ sal_Bool SAL_CALL osl_isReceiveReady ( fd_set fds; struct timeval tv; - if (pSocket == NULL) /* ENOTSOCK */ - return sal_False; + if (pSocket == nullptr) /* ENOTSOCK */ + return false; FD_ZERO(&fds); FD_SET(pSocket->m_Socket, &fds); @@ -1679,9 +1657,9 @@ sal_Bool SAL_CALL osl_isReceiveReady ( return (select(pSocket->m_Socket + 1, /* no of sockets to monitor */ &fds, /* check read operations */ - 0, /* check write ops */ - 0, /* ckeck for OOB */ - (pTimeout) ? &tv : 0)==1); /* use timeout? */ + nullptr, /* check write ops */ + nullptr, /* ckeck for OOB */ + (pTimeout) ? &tv : nullptr)==1); /* use timeout? */ } /*****************************************************************************/ @@ -1694,8 +1672,8 @@ sal_Bool SAL_CALL osl_isSendReady ( fd_set fds; struct timeval tv; - if (pSocket == NULL) /* ENOTSOCK */ - return sal_False; + if (pSocket == nullptr) /* ENOTSOCK */ + return false; FD_ZERO(&fds); FD_SET(pSocket->m_Socket, &fds); @@ -1707,10 +1685,10 @@ sal_Bool SAL_CALL osl_isSendReady ( } return (select(pSocket->m_Socket + 1, /* no of sockets to monitor */ - 0, /* check read operations */ + nullptr, /* check read operations */ &fds, /* check write ops */ - 0, /* ckeck for OOB */ - (pTimeout) ? &tv : 0)==1); /* use timeout? */ + nullptr, /* ckeck for OOB */ + (pTimeout) ? &tv : nullptr)==1); /* use timeout? */ } /*****************************************************************************/ @@ -1723,8 +1701,8 @@ sal_Bool SAL_CALL osl_isExceptionPending ( fd_set fds; struct timeval tv; - if (pSocket == NULL) /* ENOTSOCK */ - return sal_False; + if (pSocket == nullptr) /* ENOTSOCK */ + return false; FD_ZERO(&fds); FD_SET(pSocket->m_Socket, &fds); @@ -1736,10 +1714,10 @@ sal_Bool SAL_CALL osl_isExceptionPending ( } return (select(pSocket->m_Socket + 1, /* no of sockets to monitor */ - 0, /* check read operations */ - 0, /* check write ops */ + nullptr, /* check read operations */ + nullptr, /* check write ops */ &fds, /* ckeck for OOB */ - (pTimeout) ? &tv : 0)==1); /* use timeout? */ + (pTimeout) ? &tv : nullptr)==1); /* use timeout? */ } /*****************************************************************************/ @@ -1749,8 +1727,8 @@ sal_Bool SAL_CALL osl_shutdownSocket ( oslSocket pSocket, oslSocketDirection Direction) { - if (pSocket == NULL) /* ENOTSOCK */ - return sal_False; + if (pSocket == nullptr) /* ENOTSOCK */ + return false; return (shutdown(pSocket->m_Socket, DIRECTION_TO_NATIVE(Direction))==0); } @@ -1765,19 +1743,20 @@ sal_Int32 SAL_CALL osl_getSocketOption ( void* pBuffer, sal_uInt32 BufferLen) { - if (pSocket == NULL) /* ENOTSOCK */ + if (pSocket == nullptr) /* ENOTSOCK */ return osl_Socket_Error; + int len = BufferLen; if (getsockopt(pSocket->m_Socket, OPTION_LEVEL_TO_NATIVE(Level), OPTION_TO_NATIVE(Option), - (sal_Char*)pBuffer, - (int*)&BufferLen) == -1) + static_cast(pBuffer), + &len) == -1) { return -1; } - return (sal_Int32)BufferLen; + return len; } /*****************************************************************************/ @@ -1790,13 +1769,13 @@ sal_Bool SAL_CALL osl_setSocketOption ( void* pBuffer, sal_uInt32 BufferLen) { - if (pSocket == NULL) /* ENOTSOCK */ - return sal_False; + if (pSocket == nullptr) /* ENOTSOCK */ + return false; return(setsockopt(pSocket->m_Socket, OPTION_LEVEL_TO_NATIVE(Level), OPTION_TO_NATIVE(Option), - (sal_Char*)pBuffer, + static_cast(pBuffer), BufferLen) == 0); } @@ -1807,8 +1786,8 @@ sal_Bool SAL_CALL osl_enableNonBlockingMode ( oslSocket pSocket, sal_Bool On) { unsigned long Param= On ? 1 : 0; - if (pSocket == NULL) /* ENOTSOCK */ - return sal_False; + if (pSocket == nullptr) /* ENOTSOCK */ + return false; pSocket->m_Flags = Param ? (pSocket->m_Flags | OSL_SOCKET_FLAGS_NONBLOCKING) : @@ -1823,10 +1802,10 @@ sal_Bool SAL_CALL osl_enableNonBlockingMode ( oslSocket pSocket, sal_Bool On) /*****************************************************************************/ sal_Bool SAL_CALL osl_isNonBlockingMode(oslSocket pSocket) { - if (pSocket == NULL) /* ENOTSOCK */ - return sal_False; + if (pSocket == nullptr) /* ENOTSOCK */ + return false; - return (sal_Bool)((pSocket->m_Flags & OSL_SOCKET_FLAGS_NONBLOCKING) != 0); + return (pSocket->m_Flags & OSL_SOCKET_FLAGS_NONBLOCKING) != 0; } /*****************************************************************************/ @@ -1837,13 +1816,13 @@ oslSocketType SAL_CALL osl_getSocketType(oslSocket pSocket) int Type=0; int TypeSize= sizeof(Type); - if (pSocket == NULL) /* ENOTSOCK */ + if (pSocket == nullptr) /* ENOTSOCK */ return osl_Socket_TypeInvalid; if(getsockopt(pSocket->m_Socket, OPTION_LEVEL_TO_NATIVE(osl_Socket_LevelSocket), OPTION_TO_NATIVE(osl_Socket_OptionType), - (sal_Char *)&Type, + reinterpret_cast(&Type), &TypeSize) == -1) { /* error */ @@ -2088,27 +2067,27 @@ oslSocketError SAL_CALL osl_getLastSocketError(oslSocket /*Socket*/) /*****************************************************************************/ /* SocketSet */ /*****************************************************************************/ -typedef struct _TSocketSetImpl +struct oslSocketSetImpl { fd_set m_Set; /* the set of descriptors */ -} TSocketSetImpl; +}; /*****************************************************************************/ /* osl_createSocketSet */ /*****************************************************************************/ oslSocketSet SAL_CALL osl_createSocketSet() { - TSocketSetImpl* pSet; + oslSocketSetImpl* pSet; - pSet = (TSocketSetImpl*) rtl_allocateMemory(sizeof(TSocketSetImpl)); + pSet = static_cast(rtl_allocateMemory(sizeof(oslSocketSetImpl))); if(pSet) { FD_ZERO(&pSet->m_Set); } - return (oslSocketSet)pSet; + return pSet; } /*****************************************************************************/ @@ -2125,12 +2104,8 @@ void SAL_CALL osl_destroySocketSet (oslSocketSet Set) /*****************************************************************************/ void SAL_CALL osl_clearSocketSet (oslSocketSet Set) { - TSocketSetImpl* pSet; - - pSet= (TSocketSetImpl*)Set; - - if (pSet) - FD_ZERO(&pSet->m_Set); + if (Set) + FD_ZERO(&Set->m_Set); } /*****************************************************************************/ @@ -2140,14 +2115,8 @@ void SAL_CALL osl_addToSocketSet ( oslSocketSet Set, oslSocket Socket) { - TSocketSetImpl* pSet; - oslSocketImpl* pSockImpl; - - pSet= (TSocketSetImpl*)Set; - pSockImpl= (oslSocketImpl*)Socket; - - if (pSet && pSockImpl) - FD_SET(pSockImpl->m_Socket, &pSet->m_Set); + if (Set && Socket) + FD_SET(Socket->m_Socket, &Set->m_Set); } /*****************************************************************************/ @@ -2157,14 +2126,8 @@ void SAL_CALL osl_removeFromSocketSet ( oslSocketSet Set, oslSocket Socket) { - TSocketSetImpl* pSet; - oslSocketImpl* pSockImpl; - - pSet= (TSocketSetImpl*)Set; - pSockImpl= (oslSocketImpl*)Socket; - - if (pSet && pSockImpl) - FD_CLR(pSockImpl->m_Socket, &pSet->m_Set); + if (Set && Socket) + FD_CLR(Socket->m_Socket, &Set->m_Set); } /*****************************************************************************/ @@ -2174,16 +2137,10 @@ sal_Bool SAL_CALL osl_isInSocketSet ( oslSocketSet Set, oslSocket Socket) { - TSocketSetImpl* pSet; - oslSocketImpl* pSockImpl; - - pSet= (TSocketSetImpl*)Set; - pSockImpl= (oslSocketImpl*)Socket; - - if (pSet && pSockImpl) - return (FD_ISSET(pSockImpl->m_Socket, &pSet->m_Set) != 0); + if (Set && Socket) + return (FD_ISSET(Socket->m_Socket, &Set->m_Set) != 0); else - return sal_False; + return false; } /*****************************************************************************/ @@ -2197,9 +2154,6 @@ sal_Int32 SAL_CALL osl_demultiplexSocketEvents ( { int MaxHandle= 0; struct timeval tv; - TSocketSetImpl* pInSet; - TSocketSetImpl* pOutSet; - TSocketSetImpl* pOOBSet; if(pTimeout) { @@ -2208,16 +2162,11 @@ sal_Int32 SAL_CALL osl_demultiplexSocketEvents ( tv.tv_usec = pTimeout->Nanosec / 1000L; } - /* map opaque data to impl-types */ - pInSet= (TSocketSetImpl*)IncomingSet; - pOutSet= (TSocketSetImpl*)OutgoingSet; - pOOBSet= (TSocketSetImpl*)OutOfBandSet; - return select(MaxHandle, /* redundant in WIN32 */ - pInSet ? &pInSet->m_Set : 0, - pOutSet ? &pOutSet->m_Set : 0, - pOOBSet ? &pOOBSet->m_Set : 0, - pTimeout ? &tv : 0); + IncomingSet ? &IncomingSet->m_Set : nullptr, + OutgoingSet ? &OutgoingSet->m_Set : nullptr, + OutOfBandSet ? &OutOfBandSet->m_Set : nullptr, + pTimeout ? &tv : nullptr); } } diff --git a/sal/osl/w32/sockimpl.h b/sal/osl/w32/sockimpl.h index d0e56f1a80d0..fd1cd3daecab 100644 --- a/sal/osl/w32/sockimpl.h +++ b/sal/osl/w32/sockimpl.h @@ -17,8 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef _OSL_SOCKETIMPL_H_ -#define _OSL_SOCKETIMPL_H_ +#ifndef INCLUDED_SAL_OSL_W32_SOCKIMPL_H +#define INCLUDED_SAL_OSL_W32_SOCKIMPL_H #include #include @@ -44,8 +44,8 @@ struct oslSocketAddrImpl oslInterlockedCount m_nRefCount; }; -oslSocket __osl_createSocketImpl(SOCKET Socket); -void __osl_destroySocketImpl(oslSocket pImpl); +oslSocket osl_createSocketImpl_(SOCKET Socket); +void osl_destroySocketImpl_(oslSocket pImpl); /*****************************************************************************/ /* oslSocketDialupImpl */ diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx index 8c7e9d72ae5c..14478e694a60 100644 --- a/sal/osl/w32/tempfile.cxx +++ b/sal/osl/w32/tempfile.cxx @@ -23,6 +23,7 @@ #include "osl/file.h" +#include #include "file_error.h" #include "file_url.h" #include "path_helper.hxx" @@ -36,20 +37,18 @@ #ifdef __MINGW32__ #define STACK_ALLOC(p, t, n) (p) = reinterpret_cast(_alloca((n)*sizeof(t))); #else -#define STACK_ALLOC(p, t, n) __try {(p) = reinterpret_cast(_alloca((n)*sizeof(t)));} \ - __except(EXCEPTION_EXECUTE_HANDLER) {(p) = 0;} +#define STACK_ALLOC(p, t, n) __try {(p) = static_cast(_alloca((n)*sizeof(t)));} \ + __except(EXCEPTION_EXECUTE_HANDLER) {(p) = nullptr;} #endif -extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle(HANDLE hFile, sal_uInt32 uFlags); - // Temp file functions static oslFileError osl_setup_base_directory_impl_( rtl_uString* pustrDirectoryURL, rtl_uString** ppustr_base_dir) { - rtl_uString* dir_url = 0; - rtl_uString* dir = 0; + rtl_uString* dir_url = nullptr; + rtl_uString* dir = nullptr; oslFileError error = osl_File_E_None; if (pustrDirectoryURL) @@ -59,7 +58,7 @@ static oslFileError osl_setup_base_directory_impl_( if (osl_File_E_None == error) { - error = _osl_getSystemPathFromFileURL(dir_url, &dir, sal_False); + error = osl_getSystemPathFromFileURL_(dir_url, &dir, false); rtl_uString_release(dir_url); } @@ -81,9 +80,9 @@ static oslFileError osl_setup_createTempFile_impl_( { oslFileError osl_error; - OSL_PRECOND(((0 != pHandle) || (0 != ppustrTempFileURL)), "Invalid parameter!"); + OSL_PRECOND(((nullptr != pHandle) || (nullptr != ppustrTempFileURL)), "Invalid parameter!"); - if ((0 == pHandle) && (0 == ppustrTempFileURL)) + if ((nullptr == pHandle) && (nullptr == ppustrTempFileURL)) { osl_error = osl_File_E_INVAL; } @@ -92,7 +91,7 @@ static oslFileError osl_setup_createTempFile_impl_( osl_error = osl_setup_base_directory_impl_( pustrDirectoryURL, ppustr_base_dir); - *b_delete_on_close = (sal_Bool)(0 == ppustrTempFileURL); + *b_delete_on_close = nullptr == ppustrTempFileURL; } return osl_error; @@ -115,8 +114,8 @@ static oslFileError osl_win32_GetTempFileName_impl_( return osl_error; } -static sal_Bool osl_win32_CreateFile_impl_( - LPCWSTR file_name, sal_Bool b_delete_on_close, oslFileHandle* p_handle) +static bool osl_win32_CreateFile_impl_( + LPCWSTR file_name, bool b_delete_on_close, oslFileHandle* p_handle) { DWORD flags = FILE_ATTRIBUTE_NORMAL; HANDLE hFile; @@ -130,22 +129,22 @@ static sal_Bool osl_win32_CreateFile_impl_( file_name, GENERIC_READ | GENERIC_WRITE, 0, - NULL, + nullptr, TRUNCATE_EXISTING, flags, - NULL); + nullptr); // @@@ ERROR HANDLING @@@ if (IsValidHandle(hFile)) *p_handle = osl_createFileHandleFromOSHandle(hFile, osl_File_OpenFlag_Read | osl_File_OpenFlag_Write); - return (sal_Bool)IsValidHandle(hFile); + return IsValidHandle(hFile); } static oslFileError osl_createTempFile_impl_( rtl_uString* base_directory, LPWSTR tmp_name, - sal_Bool b_delete_on_close, + bool b_delete_on_close, oslFileHandle* pHandle, rtl_uString** ppustrTempFileURL) { @@ -157,15 +156,15 @@ static oslFileError osl_createTempFile_impl_( /* if file could not be opened try again */ - if ((osl_File_E_None != osl_error) || (0 == pHandle) || + if ((osl_File_E_None != osl_error) || (nullptr == pHandle) || osl_win32_CreateFile_impl_(tmp_name, b_delete_on_close, pHandle)) break; - } while(1); // try until success + } while(true); // try until success if ((osl_File_E_None == osl_error) && !b_delete_on_close) { - rtl_uString* pustr = 0; + rtl_uString* pustr = nullptr; rtl_uString_newFromStr(&pustr, reinterpret_cast(tmp_name)); osl_getFileURLFromSystemPath(pustr, ppustrTempFileURL); rtl_uString_release(pustr); @@ -179,7 +178,7 @@ oslFileError SAL_CALL osl_createTempFile( oslFileHandle* pHandle, rtl_uString** ppustrTempFileURL) { - rtl_uString* base_directory = 0; + rtl_uString* base_directory = nullptr; LPWSTR tmp_name; sal_Bool b_delete_on_close; oslFileError osl_error; @@ -235,7 +234,7 @@ oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir) } else if ( nLength ) { - rtl_uString *ustrTempPath = NULL; + rtl_uString *ustrTempPath = nullptr; if ( '\\' == lpBuffer[nLength-1] ) lpBuffer[nLength-1] = 0; diff --git a/sal/osl/w32/thread.c b/sal/osl/w32/thread.c index 28b5f1147016..02cd97ec9f83 100644 --- a/sal/osl/w32/thread.c +++ b/sal/osl/w32/thread.c @@ -18,6 +18,7 @@ */ #include "system.h" +#include #include #include @@ -30,7 +31,7 @@ /* Thread-data structure hidden behind oslThread: */ -typedef struct _osl_TThreadImpl +typedef struct { HANDLE m_hThread; /* OS-handle used for all thread-functions */ unsigned m_ThreadId; /* identifier for this thread */ @@ -51,7 +52,7 @@ static unsigned __stdcall oslWorkerWrapperFunction(void* pData) osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)pData; /* Initialize COM - Multi Threaded Apartment (MTA) for all threads */ - CoInitializeEx(0, COINIT_MULTITHREADED); /* spawned by oslCreateThread */ + CoInitializeEx(NULL, COINIT_MULTITHREADED); /* spawned by oslCreateThread */ /* call worker-function with data */ @@ -76,9 +77,9 @@ static oslThread oslCreateThread(oslWorkerFunction pWorker, OSL_ASSERT(pThreadImpl); - if ( pThreadImpl == 0 ) + if ( pThreadImpl == NULL ) { - return 0; + return NULL; } pThreadImpl->m_WorkerFunction= pWorker; @@ -93,7 +94,7 @@ static oslThread oslCreateThread(oslWorkerFunction pWorker, nFlags, /* start thread immediately or suspended */ &pThreadImpl->m_ThreadId); - if(pThreadImpl->m_hThread == 0) + if(pThreadImpl->m_hThread == NULL) { switch (errno) { @@ -116,7 +117,7 @@ static oslThread oslCreateThread(oslWorkerFunction pWorker, /* create failed */ free(pThreadImpl); - return 0; + return NULL; } return (oslThread)pThreadImpl; @@ -160,7 +161,7 @@ void SAL_CALL osl_destroyThread(oslThread Thread) { osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; - if (Thread == 0) /* valid ptr? */ + if (Thread == NULL) /* valid ptr? */ { /* thread already destroyed or not created */ return; @@ -262,7 +263,7 @@ oslThreadPriority SAL_CALL osl_getThreadPriority(const oslThread Thread) osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; /* invalid arguments ?*/ - if(pThreadImpl==0 || pThreadImpl->m_hThread==0) + if(pThreadImpl==NULL || pThreadImpl->m_hThread==NULL) { return osl_Thread_PriorityUnknown; } @@ -318,7 +319,7 @@ sal_Bool SAL_CALL osl_isThreadRunning(const oslThread Thread) osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; /* invalid arguments ?*/ - if(pThreadImpl==0 || pThreadImpl->m_hThread==0) + if(pThreadImpl==NULL || pThreadImpl->m_hThread==NULL) { return sal_False; } @@ -334,7 +335,7 @@ void SAL_CALL osl_joinWithThread(oslThread Thread) osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; /* invalid arguments?*/ - if(pThreadImpl==0 || pThreadImpl->m_hThread==0) + if(pThreadImpl==NULL || pThreadImpl->m_hThread==NULL) { /* assume thread is not running */ return; @@ -364,7 +365,7 @@ void SAL_CALL osl_terminateThread(oslThread Thread) osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; /* invalid arguments?*/ - if (pThreadImpl==0 || pThreadImpl->m_hThread==0) + if (pThreadImpl==NULL || pThreadImpl->m_hThread==NULL) { /* assume thread is not running */ return; @@ -383,7 +384,7 @@ sal_Bool SAL_CALL osl_scheduleThread(oslThread Thread) osl_yieldThread(); /* invalid arguments?*/ - if (pThreadImpl==0 || pThreadImpl->m_hThread==0) + if (pThreadImpl==NULL || pThreadImpl->m_hThread==NULL) { /* assume thread is not running */ return sal_False; @@ -425,11 +426,11 @@ void SAL_CALL osl_setThreadName(char const * name) { #endif } -typedef struct _TLS +typedef struct TLS_ { DWORD dwIndex; oslThreadKeyCallbackFunction pfnCallback; - struct _TLS *pNext, *pPrev; + struct TLS_ *pNext, *pPrev; } TLS, *PTLS; static PTLS g_pThreadKeyList = NULL; @@ -442,7 +443,7 @@ static void AddKeyToList( PTLS pTls ) EnterCriticalSection( &g_ThreadKeyListCS ); pTls->pNext = g_pThreadKeyList; - pTls->pPrev = 0; + pTls->pPrev = NULL; if ( g_pThreadKeyList ) g_pThreadKeyList->pPrev = pTls; @@ -472,7 +473,7 @@ static void RemoveKeyFromList( PTLS pTls ) } } -void SAL_CALL _osl_callThreadKeyCallbackOnThreadDetach(void) +void SAL_CALL osl_callThreadKeyCallbackOnThreadDetach(void) { PTLS pTls; @@ -506,7 +507,7 @@ oslThreadKey SAL_CALL osl_createThreadKey(oslThreadKeyCallbackFunction pCallback if ( (DWORD)-1 == (pTls->dwIndex = TlsAlloc()) ) { rtl_freeMemory( pTls ); - pTls = 0; + pTls = NULL; } else AddKeyToList( pTls ); @@ -520,7 +521,7 @@ oslThreadKey SAL_CALL osl_createThreadKey(oslThreadKeyCallbackFunction pCallback /*****************************************************************************/ void SAL_CALL osl_destroyThreadKey(oslThreadKey Key) { - if (Key != 0) + if (Key != NULL) { PTLS pTls = (PTLS)Key; @@ -535,7 +536,7 @@ void SAL_CALL osl_destroyThreadKey(oslThreadKey Key) /*****************************************************************************/ void* SAL_CALL osl_getThreadKeyData(oslThreadKey Key) { - if (Key != 0) + if (Key != NULL) { PTLS pTls = (PTLS)Key; @@ -550,7 +551,7 @@ void* SAL_CALL osl_getThreadKeyData(oslThreadKey Key) /*****************************************************************************/ sal_Bool SAL_CALL osl_setThreadKeyData(oslThreadKey Key, void *pData) { - if (Key != 0) + if (Key != NULL) { PTLS pTls = (PTLS)Key; void* pOldData = NULL; diff --git a/sal/osl/w32/thread.h b/sal/osl/w32/thread.h new file mode 100644 index 000000000000..5761b5a7fe0a --- /dev/null +++ b/sal/osl/w32/thread.h @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SAL_OSL_W32_THREAD_H +#define INCLUDED_SAL_OSL_W32_THREAD_H + +#include + +#include + +#if defined __cplusplus +extern "C" { +#endif + +void SAL_CALL osl_callThreadKeyCallbackOnThreadDetach(void); + +#if defined __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sal/osl/w32/time.c b/sal/osl/w32/time.c index 47e927f1ac84..5acb65a7d7eb 100644 --- a/sal/osl/w32/time.c +++ b/sal/osl/w32/time.c @@ -17,16 +17,16 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include "system.h" +#include +#include + #include #include #include -extern sal_Bool TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime); - -extern BOOL FileTimeToTimeValue( const FILETIME *cpFTime, TimeValue *pTimeVal ); - // osl_getSystemTime sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal) @@ -40,7 +40,7 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal) static HMODULE hModule = NULL; static GetSystemTimePreciseAsFileTime_PROC pGetSystemTimePreciseAsFileTime = NULL; - OSL_ASSERT(pTimeVal != 0); + OSL_ASSERT(pTimeVal != NULL); if ( !hModule ) { diff --git a/sal/osl/w32/time.h b/sal/osl/w32/time.h new file mode 100644 index 000000000000..91cb86e736fb --- /dev/null +++ b/sal/osl/w32/time.h @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SAL_OSL_W32_TIME_H +#define INCLUDED_SAL_OSL_W32_TIME_H + +#include + +#if defined __cplusplus +extern "C" { +#endif + +void sal_initGlobalTimer(void); + +#if defined __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx index 2320fd6197f2..475b09750826 100644 --- a/sal/qa/osl/process/osl_process.cxx +++ b/sal/qa/osl/process/osl_process.cxx @@ -39,7 +39,7 @@ #if defined HAVE_VALGRIND_HEADERS #include -#else +#elif !defined _WIN32 #define RUNNING_ON_VALGRIND false #endif @@ -95,6 +95,8 @@ inline ::rtl::OUString getExecutablePath() typedef std::vector string_container_t; +#if !defined _WIN32 + class exclude : public std::unary_function { public: @@ -154,27 +156,13 @@ namespace } } -#ifdef _WIN32 - void read_parent_environment(string_container_t* env_container) - { - LPTSTR env = reinterpret_cast(GetEnvironmentStrings()); - LPTSTR p = env; - - while (size_t l = _tcslen(p)) - { - env_container->push_back(OString(p)); - p += l + 1; - } - FreeEnvironmentStrings(env); - tidy_container(*env_container); - } -#else void read_parent_environment(string_container_t* env_container) { for (int i = 0; nullptr != environ[i]; i++) env_container->push_back(OString(environ[i])); tidy_container(*env_container); } + #endif class Test_osl_executeProcess : public CppUnit::TestFixture @@ -222,6 +210,8 @@ public: return temp_file_path; } +#if !defined _WIN32 + void read_child_environment(string_container_t* env_container) { OString temp_file_name = OUStringToOString(OUString( @@ -419,6 +409,8 @@ public: ); } +#endif + void osl_execProc_test_batch() { oslProcess process; diff --git a/sal/qa/osl/process/osl_process_child.cxx b/sal/qa/osl/process/osl_process_child.cxx index 22ab319873a3..4688f4883e9f 100644 --- a/sal/qa/osl/process/osl_process_child.cxx +++ b/sal/qa/osl/process/osl_process_child.cxx @@ -58,7 +58,7 @@ void wait_for_seconds(char* time) void w_to_a(LPCTSTR _strW, LPSTR strA, DWORD size) { LPCWSTR strW = reinterpret_cast(_strW); - WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, size, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, size, nullptr, nullptr); } void dump_env(char* file_path) diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx index 1ebdbeae31af..8cd5f1257f62 100644 --- a/sal/qa/osl/security/osl_Security.cxx +++ b/sal/qa/osl/security/osl_Security.cxx @@ -370,17 +370,18 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, sal_Char PathA[_MAX_PATH]; if (RegOpenKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hRegKey) == ERROR_SUCCESS) { - LONG lRet, lSize = sizeof(PathA); + LONG lRet; + DWORD lSize = sizeof(PathA); DWORD Type; - lRet = RegQueryValueEx(hRegKey, "AppData", NULL, &Type, ( unsigned char * )PathA, ( unsigned long * )&lSize); + lRet = RegQueryValueEx(hRegKey, "AppData", nullptr, &Type, reinterpret_cast(PathA), &lSize); if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _access( PathA, 0 ) == 0 ) ) { CPPUNIT_ASSERT_MESSAGE( "#Convert from system path to URL failed.", ::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strConfigDirectory ) ); } - lRet = RegQueryValueEx(hRegKey, "Personal", NULL, &Type, ( unsigned char * )PathA, ( unsigned long * )&lSize); + lRet = RegQueryValueEx(hRegKey, "Personal", nullptr, &Type, reinterpret_cast(PathA), &lSize); if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _access( PathA, 0 ) == 0 ) ) { CPPUNIT_ASSERT_MESSAGE( "#Convert from system path to URL failed.", @@ -398,19 +399,19 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, DWORD dwSidBufferSize = INITIAL_SIZE; DWORD cchDomainName = 0; DWORD dwDomainBufferSize = INITIAL_SIZE; - WCHAR * wszDomainName = NULL; + WCHAR * wszDomainName = nullptr; SID_NAME_USE eSidType; DWORD dwErrorCode = 0; - LPCWSTR wszAccName = ( LPWSTR ) strUserName.getStr( ); + LPCWSTR wszAccName = strUserName.getStr( ); // Create buffers for the SID and the domain name. - PSID pSid = (PSID) new BYTE[dwSidBufferSize]; - CPPUNIT_ASSERT_MESSAGE("# creating SID buffer failed.\n", pSid!= NULL ); + PSID pSid = static_cast(new BYTE[dwSidBufferSize]); + CPPUNIT_ASSERT_MESSAGE("# creating SID buffer failed.\n", pSid!= nullptr ); memset( pSid, 0, dwSidBufferSize); wszDomainName = new WCHAR[dwDomainBufferSize]; - CPPUNIT_ASSERT_MESSAGE("# creating Domain name buffer failed.\n", wszDomainName != NULL ); + CPPUNIT_ASSERT_MESSAGE("# creating Domain name buffer failed.\n", wszDomainName != nullptr ); memset(wszDomainName, 0, dwDomainBufferSize*sizeof(WCHAR)); // Obtain the SID for the account name passed. @@ -420,7 +421,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, cbSid = dwSidBufferSize; cchDomainName = dwDomainBufferSize; if (LookupAccountNameW( - NULL, // Computer name. NULL for the local computer + nullptr, // Computer name. NULL for the local computer wszAccName, pSid, // Pointer to the SID buffer. Use NULL to get the size needed, &cbSid, // Size of the SID buffer needed. @@ -443,8 +444,8 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, // Reallocate memory for the SID buffer. wprintf(L"# The SID buffer was too small. It will be reallocated.\n"); FreeSid( pSid); - pSid = (PSID) new BYTE[cbSid]; - CPPUNIT_ASSERT_MESSAGE("# re-creating SID buffer failed.\n", pSid!= NULL ); + pSid = static_cast(new BYTE[cbSid]); + CPPUNIT_ASSERT_MESSAGE("# re-creating SID buffer failed.\n", pSid!= nullptr ); memset( pSid, 0, cbSid); dwSidBufferSize = cbSid; } @@ -454,7 +455,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, wprintf(L"# The domain name buffer was too small. It will be reallocated.\n"); delete [] wszDomainName; wszDomainName = new WCHAR[cchDomainName]; - CPPUNIT_ASSERT_MESSAGE("# re-creating domain name buffer failed.\n", wszDomainName!= NULL ); + CPPUNIT_ASSERT_MESSAGE("# re-creating domain name buffer failed.\n", wszDomainName!= nullptr ); memset(wszDomainName, 0, cchDomainName*sizeof(WCHAR)); dwDomainBufferSize = cchDomainName; } @@ -481,7 +482,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, dwSubAuthorities=std::min((int) *GetSidSubAuthorityCount(pSid), 5); /* buffer length: S-SID_REVISION- + identifierauthority- + subauthorities- + NULL */ - Ident=(sal_Char * )malloc(88*sizeof(sal_Char)); + Ident=static_cast(malloc(88*sizeof(sal_Char))); /* prepare S-SID_REVISION- */ dwSidSize=wsprintf(Ident, TEXT("S-%lu-"), dwSidRev); @@ -518,7 +519,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, strUserID = ::rtl::OUString::createFromAscii( Ident ); free(Ident); - delete [] reinterpret_cast(pSid); + delete [] static_cast(pSid); delete [] wszDomainName; /// check if logged in user is administrator: @@ -535,14 +536,14 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, &AdministratorsGroup); if(b) { - if (!CheckTokenMembership( NULL, AdministratorsGroup, &b)) + if (!CheckTokenMembership( nullptr, AdministratorsGroup, &b)) { b = FALSE; } FreeSid(AdministratorsGroup); } - isAdmin = ( sal_Bool )b; + isAdmin = b; #endif diff --git a/sal/qa/osl/setthreadname/test-setthreadname.cxx b/sal/qa/osl/setthreadname/test-setthreadname.cxx index d188b07214c7..600573008eba 100644 --- a/sal/qa/osl/setthreadname/test-setthreadname.cxx +++ b/sal/qa/osl/setthreadname/test-setthreadname.cxx @@ -41,7 +41,7 @@ public: void TestThread::run() { #if defined(_WIN32) - if (std::getenv("URE_TEST_SETTHREADNAME") != 0) { + if (std::getenv("URE_TEST_SETTHREADNAME") != nullptr) { // On Windows, setting thread names appears to only take effect when the // process is being debugged, so attach a debugger now: std::cout << "set: "; diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx index 654cd2f1dbfa..234a3d5c6755 100644 --- a/sal/rtl/alloc_arena.cxx +++ b/sal/rtl/alloc_arena.cxx @@ -1100,7 +1100,7 @@ SAL_CALL rtl_arena_free ( #if defined(SAL_UNX) #include #elif defined(SAL_W32) -#define MAP_FAILED 0 +#define MAP_FAILED nullptr #endif /* SAL_UNX || SAL_W32 */ namespace @@ -1144,7 +1144,7 @@ SAL_CALL rtl_machdep_alloc ( #if defined(SAL_UNX) addr = mmap (nullptr, (size_t)(size), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); #elif defined(SAL_W32) - addr = VirtualAlloc (NULL, (SIZE_T)(size), MEM_COMMIT, PAGE_READWRITE); + addr = VirtualAlloc (nullptr, (SIZE_T)(size), MEM_COMMIT, PAGE_READWRITE); #endif /* (SAL_UNX || SAL_W32) */ if (addr != MAP_FAILED) @@ -1177,7 +1177,7 @@ SAL_CALL rtl_machdep_free ( #if defined(SAL_UNX) (void) munmap(pAddr, nSize); #elif defined(SAL_W32) - (void) VirtualFree ((LPVOID)(pAddr), (SIZE_T)(0), MEM_RELEASE); + (void) VirtualFree (pAddr, (SIZE_T)(0), MEM_RELEASE); #endif /* (SAL_UNX || SAL_W32) */ } diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx index 8540d913bba0..d91908879c70 100644 --- a/sal/rtl/alloc_cache.cxx +++ b/sal/rtl/alloc_cache.cxx @@ -1370,10 +1370,10 @@ rtl_cache_wsupdate_init() RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); g_cache_list.m_update_done = 0; - g_cache_list.m_update_cond = CreateEvent (0, TRUE, FALSE, 0); + g_cache_list.m_update_cond = CreateEvent (nullptr, TRUE, FALSE, nullptr); g_cache_list.m_update_thread = - CreateThread (NULL, 0, rtl_cache_wsupdate_all, (LPVOID)(10), 0, &dwThreadId); + CreateThread (nullptr, 0, rtl_cache_wsupdate_all, reinterpret_cast(10), 0, &dwThreadId); RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); } diff --git a/sal/systools/win32/uwinapi/sntprintf.c b/sal/systools/win32/uwinapi/sntprintf.c index 0b7db36a23c5..a46ed2e7c478 100644 --- a/sal/systools/win32/uwinapi/sntprintf.c +++ b/sal/systools/win32/uwinapi/sntprintf.c @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#define _SNPRINTF_DLLIMPORT __declspec( dllexport ) +#define LO_SNPRINTF_DLLIMPORT __declspec( dllexport ) #include #include @@ -94,7 +94,7 @@ static _TCHAR *GetLastBufferChar( _TCHAR *buffer, size_t count ) /* Implementation of snprintf following the ISO/IEC 9899:1999 (ISO C99) standard */ -_SNPRINTF_DLLIMPORT int __cdecl vsntprintf( _TCHAR *buffer, size_t count, const _TCHAR *format, va_list list ) +LO_SNPRINTF_DLLIMPORT int __cdecl vsntprintf( _TCHAR *buffer, size_t count, const _TCHAR *format, va_list list ) { int retval; @@ -132,7 +132,7 @@ _SNPRINTF_DLLIMPORT int __cdecl vsntprintf( _TCHAR *buffer, size_t count, const /* Implementation of snprintf following the ISO/IEC 9899:1999 (ISO C99) standard */ -_SNPRINTF_DLLIMPORT int __cdecl sntprintf( _TCHAR *buffer, size_t count, const _TCHAR *format, ... ) +LO_SNPRINTF_DLLIMPORT int __cdecl sntprintf( _TCHAR *buffer, size_t count, const _TCHAR *format, ... ) { va_list list; int retval; -- cgit