diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-06-19 11:57:43 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-06-19 11:57:43 +0200 |
commit | fd0649408ac52ec0c6a443c5716d50c9243bca7e (patch) | |
tree | 5c5472ebd37157ec38bef497ddad7c8fa4acfbba /sal/osl/w32 | |
parent | ea3da31396ff5a1d88efdbd6e53f2c1b1794ccb0 (diff) | |
parent | 1247c8b2350734c4f16bbc15404c3c7d56bf8523 (diff) |
Merge branch 'master' into feature/gnumake4
Conflicts:
xmlreader/prj/d.lst
Diffstat (limited to 'sal/osl/w32')
37 files changed, 444 insertions, 1615 deletions
diff --git a/sal/osl/w32/conditn.c b/sal/osl/w32/conditn.c index 9a637935b..d05dce2e2 100644 --- a/sal/osl/w32/conditn.c +++ b/sal/osl/w32/conditn.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -139,3 +140,4 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition) return (sal_Bool)(WaitForSingleObject((HANDLE)Condition, 0) == WAIT_OBJECT_0); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c index 0e1f1d864..93240e084 100755 --- a/sal/osl/w32/diagnose.c +++ b/sal/osl/w32/diagnose.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -88,7 +89,6 @@ sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nL #else HWND hWndParent; UINT nFlags; - int nCode; /* get app name or NULL if unknown (don't call assert) */ LPCSTR lpszAppName = "Error"; @@ -111,6 +111,7 @@ sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nL if ( !getenv( "DISABLE_SAL_DBGBOX" ) ) { TCHAR szBoxMessage[1024]; + int nCode; /* active popup window for the current thread */ hWndParent = GetActiveWindow(); @@ -155,8 +156,6 @@ sal_Int32 SAL_CALL osl_reportError(sal_uInt32 nType, const sal_Char* pszMessage) HWND hWndParent = GetActiveWindow(); if (hWndParent != NULL) hWndParent = GetLastActivePopup(hWndParent); - - nType = nType; /* avoid warnings */ /* set message box flags */ nFlags = MB_TASKMODAL | MB_ICONERROR | MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_SETFOREGROUND; @@ -165,7 +164,8 @@ sal_Int32 SAL_CALL osl_reportError(sal_uInt32 nType, const sal_Char* pszMessage) // display the assert nDisposition = MessageBox(hWndParent, pszMessage, "Exception!", nFlags); - + (void)nType; //unused, but part of public API/ABI return nDisposition; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/dllentry.c b/sal/osl/w32/dllentry.c index 3c1d1195d..09628d75f 100644 --- a/sal/osl/w32/dllentry.c +++ b/sal/osl/w32/dllentry.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -89,17 +90,9 @@ extern BOOL (WINAPI *_pRawDllMain)(HANDLE, DWORD, LPVOID) = _RawDllMain; #endif //------------------------------------------------------------------------------ -// globales -//------------------------------------------------------------------------------ - -DWORD g_dwPlatformId = VER_PLATFORM_WIN32_WINDOWS; // remember plattform - -//------------------------------------------------------------------------------ // DllMain //------------------------------------------------------------------------------ -#ifdef _M_IX86 int osl_isSingleCPU = 0; -#endif #ifdef __MINGW32__ @@ -176,9 +169,7 @@ static BOOL WINAPI _RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvR case DLL_PROCESS_ATTACH: { #endif - OSVERSIONINFO aInfo; -#ifdef _M_IX86 SYSTEM_INFO SystemInfo; GetSystemInfo(&SystemInfo); @@ -192,9 +183,11 @@ static BOOL WINAPI _RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvR if ( SystemInfo.dwNumberOfProcessors == 1 ) { osl_isSingleCPU = 1; } -#endif + +#if OSL_DEBUG_LEVEL < 2 /* Suppress file error messages from system like "Floppy A: not inserted" */ SetErrorMode( SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS ); +#endif /* initialize global mutex */ g_Mutex = osl_createMutex(); @@ -202,13 +195,6 @@ static BOOL WINAPI _RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvR /* initialize "current directory" mutex */ g_CurrentDirectoryMutex = osl_createMutex(); - - /* initialize Win9x unicode functions */ - aInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); - - if ( GetVersionEx(&aInfo) ) - g_dwPlatformId = aInfo.dwPlatformId; - g_dwTLSTextEncodingIndex = TlsAlloc(); InitializeCriticalSection( &g_ThreadKeyListCS ); @@ -368,3 +354,5 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) return TRUE; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx index bed2f39cc..1bb676417 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -424,7 +425,7 @@ oslFileError FileHandle_Impl::readFileAt ( return osl_File_E_None; } - SIZE_T const bytes = std::min(m_buflen - bufpos, nBytesRequested); + 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; } @@ -494,7 +495,7 @@ oslFileError FileHandle_Impl::writeFileAt ( m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone); } - SIZE_T const bytes = std::min(m_bufsiz - bufpos, nBytesToWrite); + 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; @@ -826,13 +827,6 @@ SAL_CALL osl_mapFile( return osl_File_E_OVERFLOW; SIZE_T const nLength = sal::static_int_cast< SIZE_T >(uLength); - OSVERSIONINFO osinfo; - osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - (void)::GetVersionEx(&osinfo); - - if (VER_PLATFORM_WIN32_NT != osinfo.dwPlatformId) - return osl_File_E_NOSYS; // Unsupported - FileMapping aMap( ::CreateFileMapping (pImpl->m_hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL) ); if (!IsValidHandle(aMap.m_handle)) return oslTranslateFileError( GetLastError() ); @@ -1192,3 +1186,5 @@ oslFileError SAL_CALL osl_moveFile( rtl_uString* strPath, rtl_uString *strDestPa return error; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx index 355362eb4..3e3b03a43 100644 --- a/sal/osl/w32/file_dirvol.cxx +++ b/sal/osl/w32/file_dirvol.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,12 +28,13 @@ #define UNICODE #define _UNICODE -#define _WIN32_WINNT_0x0500 +#define _WIN32_WINNT 0x0500 #include "systools/win32/uwinapi.h" #include "osl/file.h" #include "file_url.h" +#include <sal/macros.h> #include "file_error.h" #include "path_helper.hxx" @@ -48,8 +50,6 @@ #endif //##################################################### -#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0]))) - static const wchar_t UNC_PREFIX[] = L"\\\\"; static const wchar_t BACKSLASH = '\\'; static const wchar_t SLASH = '/'; @@ -145,7 +145,7 @@ namespace /* private */ //##################################################### inline bool is_UNC_path(const sal_Unicode* path) - { return (0 == wcsncmp(UNC_PREFIX, reinterpret_cast<LPCWSTR>(path), ELEMENTS_OF_ARRAY(UNC_PREFIX) - 1)); } + { return (0 == wcsncmp(UNC_PREFIX, reinterpret_cast<LPCWSTR>(path), SAL_N_ELEMENTS(UNC_PREFIX) - 1)); } //##################################################### inline bool is_UNC_path(const rtl::OUString& path) @@ -844,7 +844,7 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirect //##################################################### static oslFileError SAL_CALL osl_getNextNetResource( - oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint ) + oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/ ) { Directory_Impl *pDirImpl = (Directory_Impl *)Directory; DirectoryItem_Impl *pItemImpl = NULL; @@ -852,8 +852,6 @@ static oslFileError SAL_CALL osl_getNextNetResource( LPNETRESOURCEW lpNetResource = (LPNETRESOURCEW)buffer; DWORD dwError, dwCount, dwBufSize; - uHint = uHint; /* to get no warning */ - if ( !pItem ) return osl_File_E_INVAL; *pItem = NULL; @@ -892,13 +890,11 @@ static oslFileError SAL_CALL osl_getNextNetResource( //##################################################### static oslFileError SAL_CALL osl_getNextDrive( - oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint ) + oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/ ) { Directory_Impl *pDirImpl = (Directory_Impl *)Directory; DirectoryItem_Impl *pItemImpl = NULL; BOOL fSuccess; - - uHint = uHint; /* avoid warnings */ if ( !pItem ) return osl_File_E_INVAL; @@ -936,14 +932,12 @@ static oslFileError SAL_CALL osl_getNextDrive( //##################################################### static oslFileError SAL_CALL osl_getNextFileItem( - oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint) + oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/) { Directory_Impl *pDirImpl = (Directory_Impl *)Directory; DirectoryItem_Impl *pItemImpl = NULL; BOOL fFound; - uHint = uHint; /* avoid warnings */ - if ( !pItem ) return osl_File_E_INVAL; *pItem = NULL; @@ -1036,7 +1030,7 @@ oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory) } break; default: - OSL_ENSURE( 0, "Invalid directory type" ); + OSL_FAIL( "Invalid directory type" ); break; } @@ -1249,16 +1243,16 @@ bool is_floppy_volume_mount_point(const rtl::OUString& path) osl::systemPathEnsureSeparator(p); TCHAR vn[51]; - if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, ELEMENTS_OF_ARRAY(vn))) + if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, SAL_N_ELEMENTS(vn))) { TCHAR vnfloppy[51]; if (is_floppy_A_present() && - GetVolumeNameForVolumeMountPoint(FLOPPY_A, vnfloppy, ELEMENTS_OF_ARRAY(vnfloppy)) && + GetVolumeNameForVolumeMountPoint(FLOPPY_A, vnfloppy, SAL_N_ELEMENTS(vnfloppy)) && (0 == wcscmp(vn, vnfloppy))) return true; if (is_floppy_B_present() && - GetVolumeNameForVolumeMountPoint(FLOPPY_B, vnfloppy, ELEMENTS_OF_ARRAY(vnfloppy)) && + GetVolumeNameForVolumeMountPoint(FLOPPY_B, vnfloppy, SAL_N_ELEMENTS(vnfloppy)) && (0 == wcscmp(vn, vnfloppy))) return true; } @@ -1321,7 +1315,7 @@ static UINT get_volume_mount_point_drive_type(const rtl::OUString& path) osl::systemPathEnsureSeparator(p); TCHAR vn[51]; - if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, ELEMENTS_OF_ARRAY(vn))) + if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, SAL_N_ELEMENTS(vn))) return GetDriveType(vn); return DRIVE_NO_ROOT_DIR; @@ -1572,7 +1566,7 @@ static oslFileError SAL_CALL osl_getDriveInfo( case DRIVE_REMOTE: { TCHAR szBuffer[1024]; - DWORD const dwBufsizeConst = ELEMENTS_OF_ARRAY(szBuffer); + DWORD const dwBufsizeConst = SAL_N_ELEMENTS(szBuffer); DWORD dwBufsize = dwBufsizeConst; DWORD dwResult = WNetGetConnection( cDrive, szBuffer, &dwBufsize ); @@ -1591,7 +1585,7 @@ static oslFileError SAL_CALL osl_getDriveInfo( case DRIVE_FIXED: { TCHAR szVolumeNameBuffer[1024]; - DWORD const dwBufsizeConst = ELEMENTS_OF_ARRAY(szVolumeNameBuffer); + DWORD const dwBufsizeConst = SAL_N_ELEMENTS(szVolumeNameBuffer); if ( GetVolumeInformation( cRoot, szVolumeNameBuffer, dwBufsizeConst, NULL, NULL, NULL, NULL, 0 ) ) { @@ -1865,3 +1859,5 @@ oslFileError SAL_CALL osl_setFileTime( else return osl_File_E_None; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/file_error.c b/sal/osl/w32/file_error.c index 790255145..45ad7ed18 100644 --- a/sal/osl/w32/file_error.c +++ b/sal/osl/w32/file_error.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,13 +28,14 @@ #define UNICODE #define _UNICODE -#define _WIN32_WINNT_0x0500 +#define _WIN32_WINNT 0x0500 #include "systools/win32/uwinapi.h" #include "file_error.h" #include "osl/diagnose.h" #include "osl/thread.h" +#include <sal/macros.h> /* OS error to oslFileError values mapping table */ struct osl_file_error_entry @@ -108,7 +110,7 @@ static const struct osl_file_error_entry errtable[] = { oslFileError oslTranslateFileError (/*DWORD*/ unsigned long dwError) { - static const int n = sizeof(errtable)/sizeof(errtable[0]); + static const int n = SAL_N_ELEMENTS(errtable); int i; for (i = 0; i < n; ++i ) @@ -146,6 +148,8 @@ void _osl_warnFile( const char *message, rtl_uString *ustrFile ) message = szBuffer; } - OSL_ENSURE( 0, message ); + OSL_FAIL( message ); } #endif /* OSL_DEBUG_LEVEL */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/file_error.h b/sal/osl/w32/file_error.h index be4d75cdb..5ed392e3a 100644 --- a/sal/osl/w32/file_error.h +++ b/sal/osl/w32/file_error.h @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -49,3 +50,5 @@ void _osl_warnFile (const char * message, rtl_uString * ustrFile); #endif #endif /* INCLUDED_OSL_FILE_ERROR_H */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx index 246874a42..2691cddd3 100644 --- a/sal/osl/w32/file_url.cxx +++ b/sal/osl/w32/file_url.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,10 +28,11 @@ #define UNICODE #define _UNICODE -#define _WIN32_WINNT_0x0500 +#define _WIN32_WINNT 0x0500 #include "systools/win32/uwinapi.h" #include "file_url.h" +#include <sal/macros.h> #include "file_error.h" #include "rtl/alloc.h" @@ -49,8 +51,6 @@ #define OSL_ENSURE_FILE( cond, msg, file ) ((void)0) #endif -#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0]))) - #define WSTR_SYSTEM_ROOT_PATH L"\\\\.\\" #define WSTR_LONG_PATH_PREFIX L"\\\\?\\" #define WSTR_LONG_PATH_PREFIX_UNC L"\\\\?\\UNC\\" @@ -89,9 +89,10 @@ static BOOL IsValidFilePathComponent( case '.': if ( dwFlags & VALIDATEPATH_ALLOW_ELLIPSE ) { - if ( 1 == lpCurrent - lpComponent ) + if ( (dwFlags & VALIDATEPATH_ALLOW_INVALID_SPACE_AND_PERIOD) || + 1 == lpCurrent - lpComponent ) { - /* Current directory is O.K. */ + /* Either do allow periods anywhere, or current directory */ lpComponentEnd = lpCurrent; break; } @@ -104,8 +105,13 @@ static BOOL IsValidFilePathComponent( } case 0: case ' ': - lpComponentEnd = lpCurrent - 1; - fValid = FALSE; + if ( dwFlags & VALIDATEPATH_ALLOW_INVALID_SPACE_AND_PERIOD ) + lpComponentEnd = lpCurrent; + else + { + lpComponentEnd = lpCurrent - 1; + fValid = FALSE; + } break; default: lpComponentEnd = lpCurrent; @@ -252,16 +258,16 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u DWORD dwCandidatPathType = PATHTYPE_ERROR; - if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, reinterpret_cast<const sal_Unicode *>(WSTR_LONG_PATH_PREFIX_UNC), ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX_UNC) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) ) + if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, reinterpret_cast<const sal_Unicode *>(WSTR_LONG_PATH_PREFIX_UNC), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) ) { /* This is long path in UNC notation */ - lpComponent = lpszPath + ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX_UNC) - 1; + lpComponent = lpszPath + SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1; dwCandidatPathType = PATHTYPE_ABSOLUTE_UNC | PATHTYPE_IS_LONGPATH; } - else if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, reinterpret_cast<const sal_Unicode *>(WSTR_LONG_PATH_PREFIX), ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1 ) ) + else if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, reinterpret_cast<const sal_Unicode *>(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) ) { /* This is long path */ - lpComponent = lpszPath + ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1; + lpComponent = lpszPath + SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1; if ( _istalpha( lpComponent[0] ) && ':' == lpComponent[1] ) { @@ -297,14 +303,7 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u if ( !lpComponent ) { - #if 0 - /* We only have a Server specification what is invalid */ - - lpComponent = lpszPath; - fValid = FALSE; - #else dwPathType |= PATHTYPE_IS_SERVER; - #endif } else { @@ -375,7 +374,7 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u lpComponent = lpszPath + i; } - fValid = IsValidFilePathComponent( lpComponent, &lpComponent, dwFlags ); + fValid = IsValidFilePathComponent( lpComponent, &lpComponent, dwFlags | VALIDATEPATH_ALLOW_INVALID_SPACE_AND_PERIOD); if ( fValid && lpComponent ) { @@ -555,14 +554,14 @@ DWORD GetCaseCorrectPathName( /* Special handling for "\\.\" as system root */ if ( lpszShortPath && 0 == wcscmp( lpszShortPath, WSTR_SYSTEM_ROOT_PATH ) ) { - if ( cchBuffer >= ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) ) + if ( cchBuffer >= SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) ) { wcscpy( lpszLongPath, WSTR_SYSTEM_ROOT_PATH ); - return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1; + return SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1; } else { - return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1; + return SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1; } } else if ( lpszShortPath ) @@ -602,6 +601,11 @@ static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedUR { switch ( *pSrc ) { + case 0: + case '?': + case '#': + bValidEncoded = false; + break; case '%': { sal_Char aToken[3]; @@ -766,7 +770,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p /* Indicates local root */ if ( nDecodedLen == nSkip ) - rtl_uString_newFromStr_WithLength( &strTempPath, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1 ); + rtl_uString_newFromStr_WithLength( &strTempPath, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ); else { /* do not separate the directory and file case, so the maximal path lengs without prefix is MAX_PATH-12 */ @@ -783,8 +787,8 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p sal_False ); if ( nNewLen <= MAX_PATH - 12 - || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1, ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1 ) - || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX), ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1 ) ) + || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1, SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ) + || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) ) { rtl_uString_newFromStr_WithLength( &strTempPath, aBuf, nNewLen ); } @@ -793,7 +797,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p /* it should be an UNC path, use the according prefix */ rtl_uString *strSuffix = NULL; rtl_uString *strPrefix = NULL; - rtl_uString_newFromStr_WithLength( &strPrefix, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX_UNC), ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX_UNC ) - 1 ); + rtl_uString_newFromStr_WithLength( &strPrefix, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX_UNC), SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX_UNC ) - 1 ); rtl_uString_newFromStr_WithLength( &strSuffix, aBuf + 2, nNewLen - 2 ); rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix ); @@ -805,7 +809,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p { rtl_uString *strSuffix = NULL; rtl_uString *strPrefix = NULL; - rtl_uString_newFromStr_WithLength( &strPrefix, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX), ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX ) - 1 ); + rtl_uString_newFromStr_WithLength( &strPrefix, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX ) - 1 ); rtl_uString_newFromStr_WithLength( &strSuffix, aBuf, nNewLen ); rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix ); @@ -874,7 +878,7 @@ oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** switch ( dwPathType & PATHTYPE_MASK_TYPE ) { case PATHTYPE_ABSOLUTE_UNC: - nIgnore = ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX_UNC ) - 1; + nIgnore = SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX_UNC ) - 1; OSL_ENSURE( nIgnore == 8, "Unexpected long path UNC prefix!" ); /* generate the normal UNC path */ @@ -887,7 +891,7 @@ oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** break; case PATHTYPE_ABSOLUTE_LOCAL: - nIgnore = ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX ) - 1; + nIgnore = SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX ) - 1; OSL_ENSURE( nIgnore == 4, "Unexpected long path prefix!" ); /* generate the normal path */ @@ -899,7 +903,7 @@ oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** break; default: - OSL_ASSERT( "Unexpected long path format!" ); + OSL_FAIL( "Unexpected long path format!" ); rtl_uString_newReplace( &strTempPath, strPath, '\\', '/' ); break; } @@ -1141,3 +1145,5 @@ oslFileError SAL_CALL osl_getCanonicalName( rtl_uString *strRequested, rtl_uStri rtl_uString_newFromString(strValid, strRequested); return osl_File_E_None; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/file_url.h b/sal/osl/w32/file_url.h index 8af4b8a59..3652dffb1 100644 --- a/sal/osl/w32/file_url.h +++ b/sal/osl/w32/file_url.h @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -61,6 +62,7 @@ extern "C" { #define VALIDATEPATH_ALLOW_ELLIPSE 0x0002 #define VALIDATEPATH_ALLOW_RELATIVE 0x0004 #define VALIDATEPATH_ALLOW_UNC 0x0008 +#define VALIDATEPATH_ALLOW_INVALID_SPACE_AND_PERIOD 0x0010 #define MAX_LONG_PATH 32767 @@ -94,3 +96,5 @@ oslFileError _osl_getFileURLFromSystemPath ( #endif #endif /* INCLUDED_OSL_FILE_URL_H */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/interlck.c b/sal/osl/w32/interlck.c index b53bd4156..799437dd2 100644 --- a/sal/osl/w32/interlck.c +++ b/sal/osl/w32/interlck.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -140,3 +141,5 @@ oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* return (InterlockedDecrement(pCount)); } #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/libutil.c b/sal/osl/w32/libutil.c deleted file mode 100644 index 4271bb4bb..000000000 --- a/sal/osl/w32/libutil.c +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifdef _MSC_VER -#pragma warning(push,1) /* disable warnings within system headers */ -#endif -#include <windows.h> -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -static BOOL g_bInit = FALSE; -static DWORD g_dwPlatformId = VER_PLATFORM_WIN32_WINDOWS; - -DWORD GetPlatformId() -{ - - if (!g_bInit) - { - OSVERSIONINFO aInfo; - - aInfo.dwOSVersionInfoSize = sizeof(aInfo); - if (GetVersionEx(&aInfo)) - g_dwPlatformId = aInfo.dwPlatformId; - - g_bInit = TRUE; - } - - return g_dwPlatformId; -} diff --git a/sal/osl/w32/MAKEFILE.MK b/sal/osl/w32/makefile.mk index 474904884..08e8745a9 100644 --- a/sal/osl/w32/MAKEFILE.MK +++ b/sal/osl/w32/makefile.mk @@ -29,6 +29,7 @@ PRJ=..$/.. PRJNAME=sal TARGET=cpposl +ENABLE_EXCEPTIONS=TRUE USE_LDUMP2=TRUE PROJECTPCH4DLL=TRUE @@ -70,7 +71,6 @@ SLOFILES= $(SLO)$/conditn.obj \ $(SLO)$/profile.obj \ $(SLO)$/time.obj \ $(SLO)$/signal.obj \ - $(SLO)$/pipeimpl.obj \ $(SLO)$/pipe.obj \ $(SLO)$/util.obj \ $(SLO)$/file.obj\ @@ -84,7 +84,6 @@ SLOFILES= $(SLO)$/conditn.obj \ OBJFILES= $(OBJ)$/conditn.obj \ $(OBJ)$/diagnose.obj \ - $(OBJ)$/libutil.obj \ $(OBJ)$/semaphor.obj \ $(OBJ)$/socket.obj \ $(OBJ)$/interlck.obj \ @@ -97,7 +96,6 @@ OBJFILES= $(OBJ)$/conditn.obj \ $(OBJ)$/profile.obj \ $(OBJ)$/time.obj \ $(OBJ)$/signal.obj \ - $(OBJ)$/pipeimpl.obj \ $(OBJ)$/pipe.obj \ $(OBJ)$/util.obj \ $(OBJ)$/file.obj\ @@ -114,5 +112,3 @@ OBJFILES= $(OBJ)$/conditn.obj \ # --- Targets ------------------------------------------------------ .INCLUDE : target.mk - - diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx index 8fc1dbb8b..a332d3a36 100755..100644 --- a/sal/osl/w32/module.cxx +++ b/sal/osl/w32/module.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -25,7 +26,13 @@ * ************************************************************************/ +#ifdef __MINGW32__ +extern "C" { +#endif #include "system.h" +#ifdef __MINGW32__ +} +#endif #include <tlhelp32.h> #include "file_url.h" @@ -46,10 +53,12 @@ /*****************************************************************************/ /* osl_loadModule */ /*****************************************************************************/ -oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMode ) +oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldMode*/ ) { HINSTANCE hInstance; +#if OSL_DEBUG_LEVEL < 2 UINT errorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); +#endif rtl_uString* Module = NULL; oslModule ret = 0; oslFileError nError; @@ -57,9 +66,7 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMod RTL_LOGFILE_TRACE1( "{ osl_loadModule start: %S", (LPTSTR)&strModuleName->buffer ); OSL_ASSERT(strModuleName); - - nRtldMode = nRtldMode; /* avoid warnings */ - + nError = osl_getSystemPathFromFileURL(strModuleName, &Module); if ( osl_File_E_None != nError ) @@ -80,13 +87,13 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMod { std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec(Module->length + 1); DWORD len = GetShortPathNameW(reinterpret_cast<LPCWSTR>(Module->buffer), - &vec[0], Module->length + 1); + reinterpret_cast<LPWSTR>(&vec[0]), Module->length + 1); if (len ) { - hInstance = LoadLibraryW(&vec[0]); + hInstance = LoadLibraryW(reinterpret_cast<LPWSTR>(&vec[0])); if (hInstance == NULL) - hInstance = LoadLibraryExW(&vec[0], NULL, + hInstance = LoadLibraryExW(reinterpret_cast<LPWSTR>(&vec[0]), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); } } @@ -97,7 +104,9 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMod ret = (oslModule) hInstance; rtl_uString_release(Module); +#if OSL_DEBUG_LEVEL < 2 SetErrorMode(errorMode); +#endif RTL_LOGFILE_TRACE1( "} osl_loadModule end: %S", (LPTSTR)&strModuleName->buffer ); @@ -105,6 +114,37 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMod } /*****************************************************************************/ +/* osl_loadModuleAscii */ +/*****************************************************************************/ +oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nRtldMode ) +{ + (void) nRtldMode; /* avoid warnings */ + + HINSTANCE hInstance; + UINT errorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); + oslModule ret = 0; + + RTL_LOGFILE_TRACE1( "{ osl_loadModule start: %s", pModuleName ); + + OSL_ASSERT(pModuleName); + + hInstance = LoadLibrary(pModuleName); + if (hInstance == NULL) + hInstance = LoadLibraryEx(pModuleName, NULL, + LOAD_WITH_ALTERED_SEARCH_PATH); + + if (hInstance <= (HINSTANCE)HINSTANCE_ERROR) + hInstance = 0; + + ret = (oslModule) hInstance; + SetErrorMode(errorMode); + + RTL_LOGFILE_TRACE1( "} osl_loadModule end: %s", pModuleName ); + + return ret; +} + +/*****************************************************************************/ /* osl_getModuleHandle */ /*****************************************************************************/ @@ -207,73 +247,6 @@ osl_getAsciiFunctionSymbol( oslModule Module, const sal_Char *pSymbol ) #undef LPMODULEENTRY32 #endif -typedef HANDLE (WINAPI *CreateToolhelp32Snapshot_PROC)( DWORD dwFlags, DWORD th32ProcessID ); -typedef BOOL (WINAPI *Module32First_PROC)( HANDLE hSnapshot, LPMODULEENTRY32 lpme32 ); -typedef BOOL (WINAPI *Module32Next_PROC)( HANDLE hSnapshot, LPMODULEENTRY32 lpme32 ); - -static sal_Bool SAL_CALL _osl_addressGetModuleURL_Windows( void *pv, rtl_uString **pustrURL ) -{ - sal_Bool bSuccess = sal_False; /* Assume failure */ - HMODULE hModKernel32 = GetModuleHandleA( "KERNEL32.DLL" ); - - if ( hModKernel32 ) - { - CreateToolhelp32Snapshot_PROC lpfnCreateToolhelp32Snapshot = (CreateToolhelp32Snapshot_PROC)GetProcAddress( hModKernel32, "CreateToolhelp32Snapshot" ); - Module32First_PROC lpfnModule32First = (Module32First_PROC)GetProcAddress( hModKernel32, "Module32First" ); - Module32Next_PROC lpfnModule32Next = (Module32Next_PROC)GetProcAddress( hModKernel32, "Module32Next" ); - - if ( lpfnCreateToolhelp32Snapshot && lpfnModule32First && lpfnModule32Next ) - { - HANDLE hModuleSnap = NULL; - DWORD dwProcessId = GetCurrentProcessId(); - - // Take a snapshot of all modules in the specified process. - - hModuleSnap = lpfnCreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId ); - - if ( INVALID_HANDLE_VALUE != hModuleSnap ) - { - MODULEENTRY32 me32 = {0}; - - // Fill the size of the structure before using it. - - me32.dwSize = sizeof(MODULEENTRY32); - - // Walk the module list of the process, and find the module of - // interest. Then copy the information to the buffer pointed - // to by lpMe32 so that it can be returned to the caller. - - if ( lpfnModule32First(hModuleSnap, &me32) ) - { - do - { - if ( (BYTE *)pv >= (BYTE *)me32.hModule && (BYTE *)pv < (BYTE *)me32.hModule + me32.modBaseSize ) - { - rtl_uString *ustrSysPath = NULL; - - rtl_string2UString( &ustrSysPath, me32.szExePath, strlen(me32.szExePath), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); - OSL_ASSERT(ustrSysPath != NULL); - osl_getFileURLFromSystemPath( ustrSysPath, pustrURL ); - rtl_uString_release( ustrSysPath ); - - bSuccess = sal_True; - } - - } while ( !bSuccess && lpfnModule32Next( hModuleSnap, &me32 ) ); - } - - - // Do not forget to clean up the snapshot object. - - CloseHandle (hModuleSnap); - } - - } - } - - return bSuccess; -} - /***************************************************************************************/ /* Implementation for Windows NT, 2K and XP (2K and XP could use the above method too) */ /***************************************************************************************/ @@ -411,8 +384,6 @@ typedef BOOL (WINAPI *GetModuleInformation_PROC)( DWORD cb // size of the structure ); -#define bufsizeof(buffer) (sizeof(buffer) / sizeof((buffer)[0])) - /* This version can fail because PSAPI.DLL is not always part of NT 4 despite MSDN Libary 6.0a say so */ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pustrURL ) @@ -475,10 +446,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 */ - if ( IS_NT ) - return _osl_addressGetModuleURL_NT( pv, pustrURL ) || _osl_addressGetModuleURL_NT4( pv, pustrURL ); - else - return _osl_addressGetModuleURL_Windows( pv, pustrURL ); + return _osl_addressGetModuleURL_NT( pv, pustrURL ) || _osl_addressGetModuleURL_NT4( pv, pustrURL ); } /*****************************************************************************/ @@ -501,3 +469,4 @@ sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress( oslGenericFunction addr, } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/mutex.c b/sal/osl/w32/mutex.c index dbb568d01..009670c2f 100644 --- a/sal/osl/w32/mutex.c +++ b/sal/osl/w32/mutex.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -36,66 +37,18 @@ CRITICAL_SECTION structure. */ -typedef struct _oslMutexImpl { - CRITICAL_SECTION m_Mutex; - int m_Locks; - DWORD m_Owner; - DWORD m_Requests; -} oslMutexImpl; - -static BOOL (WINAPI *lpfTryEnterCriticalSection)(LPCRITICAL_SECTION) - = (BOOL (WINAPI *)(LPCRITICAL_SECTION))0xFFFFFFFF; - -static CRITICAL_SECTION MutexLock; - /*****************************************************************************/ /* osl_createMutex */ /*****************************************************************************/ oslMutex SAL_CALL osl_createMutex(void) { - oslMutexImpl *pMutexImpl; + CRITICAL_SECTION *pMutexImpl; - /* Window 95 does not support "TryEnterCriticalSection" */ - - if (lpfTryEnterCriticalSection == - (BOOL (WINAPI *)(LPCRITICAL_SECTION))0xFFFFFFFF) - { - OSVERSIONINFO VersionInformation = - - { - sizeof(OSVERSIONINFO), - 0, - 0, - 0, - 0, - "", - }; - - /* ts: Window 98 does not support "TryEnterCriticalSection" but export the symbol !!! - calls to that symbol always returns FALSE */ - if ( - GetVersionEx(&VersionInformation) && - (VersionInformation.dwPlatformId == VER_PLATFORM_WIN32_NT) - ) - { - lpfTryEnterCriticalSection = (BOOL (WINAPI *)(LPCRITICAL_SECTION)) - GetProcAddress(GetModuleHandle("KERNEL32"), - "TryEnterCriticalSection"); - } - else - { - lpfTryEnterCriticalSection = (BOOL (WINAPI *)(LPCRITICAL_SECTION))NULL; - } - - - InitializeCriticalSection(&MutexLock); - } - - pMutexImpl= calloc(sizeof(oslMutexImpl), 1); + pMutexImpl = calloc(sizeof(CRITICAL_SECTION), 1); OSL_ASSERT(pMutexImpl); /* alloc successful? */ - InitializeCriticalSection(&pMutexImpl->m_Mutex); + InitializeCriticalSection(pMutexImpl); return (oslMutex)pMutexImpl; } @@ -105,11 +58,11 @@ oslMutex SAL_CALL osl_createMutex(void) /*****************************************************************************/ void SAL_CALL osl_destroyMutex(oslMutex Mutex) { - oslMutexImpl *pMutexImpl = (oslMutexImpl *)Mutex; + CRITICAL_SECTION *pMutexImpl = (CRITICAL_SECTION *)Mutex; if (pMutexImpl) { - DeleteCriticalSection(&pMutexImpl->m_Mutex); + DeleteCriticalSection(pMutexImpl); free(pMutexImpl); } } @@ -119,26 +72,11 @@ void SAL_CALL osl_destroyMutex(oslMutex Mutex) /*****************************************************************************/ sal_Bool SAL_CALL osl_acquireMutex(oslMutex Mutex) { - oslMutexImpl *pMutexImpl = (oslMutexImpl *)Mutex; + CRITICAL_SECTION *pMutexImpl = (CRITICAL_SECTION *)Mutex; OSL_ASSERT(Mutex); - if (lpfTryEnterCriticalSection == NULL) - { - EnterCriticalSection(&MutexLock); - pMutexImpl->m_Requests++; - LeaveCriticalSection(&MutexLock); - - EnterCriticalSection(&pMutexImpl->m_Mutex); - - EnterCriticalSection(&MutexLock); - pMutexImpl->m_Requests--; - if (pMutexImpl->m_Locks++ == 0) - pMutexImpl->m_Owner = GetCurrentThreadId(); - LeaveCriticalSection(&MutexLock); - } - else - EnterCriticalSection(&pMutexImpl->m_Mutex); + EnterCriticalSection(pMutexImpl); return sal_True; } @@ -148,25 +86,11 @@ sal_Bool SAL_CALL osl_acquireMutex(oslMutex Mutex) /*****************************************************************************/ sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex Mutex) { - sal_Bool ret = sal_False; - oslMutexImpl *pMutexImpl = (oslMutexImpl *)Mutex; + CRITICAL_SECTION *pMutexImpl = (CRITICAL_SECTION *)Mutex; OSL_ASSERT(Mutex); - if (lpfTryEnterCriticalSection != NULL) - return (sal_Bool)(lpfTryEnterCriticalSection(&pMutexImpl->m_Mutex) != FALSE); - else - { - EnterCriticalSection(&MutexLock); - - if ( ((pMutexImpl->m_Requests == 0) && (pMutexImpl->m_Locks == 0)) || - (pMutexImpl->m_Owner == GetCurrentThreadId()) ) - ret = osl_acquireMutex(Mutex); - - LeaveCriticalSection(&MutexLock); - } - - return ret; + return (sal_Bool)(TryEnterCriticalSection(pMutexImpl) != FALSE); } /*****************************************************************************/ @@ -174,21 +98,11 @@ sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex Mutex) /*****************************************************************************/ sal_Bool SAL_CALL osl_releaseMutex(oslMutex Mutex) { - oslMutexImpl *pMutexImpl = (oslMutexImpl *)Mutex; + CRITICAL_SECTION *pMutexImpl = (CRITICAL_SECTION *)Mutex; OSL_ASSERT(Mutex); - if (lpfTryEnterCriticalSection == NULL) - { - EnterCriticalSection(&MutexLock); - - if (--(pMutexImpl->m_Locks) == 0) - pMutexImpl->m_Owner = 0; - - LeaveCriticalSection(&MutexLock); - } - - LeaveCriticalSection(&pMutexImpl->m_Mutex); + LeaveCriticalSection(pMutexImpl); return sal_True; } @@ -204,3 +118,5 @@ oslMutex * SAL_CALL osl_getGlobalMutex(void) { return &g_Mutex; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/nlsupport.c b/sal/osl/w32/nlsupport.c index 3519177ed..9affc96bb 100644 --- a/sal/osl/w32/nlsupport.c +++ b/sal/osl/w32/nlsupport.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -229,3 +230,4 @@ void _imp_getProcessLocale( rtl_Locale ** ppLocale ) } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/path_helper.cxx b/sal/osl/w32/path_helper.cxx index dd78f9604..744cbb77b 100644 --- a/sal/osl/w32/path_helper.cxx +++ b/sal/osl/w32/path_helper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -43,8 +44,8 @@ Constants ******************************************************************/ -const rtl::OUString BACKSLASH = rtl::OUString::createFromAscii("\\"); -const rtl::OUString SLASH = rtl::OUString::createFromAscii("/"); +const rtl::OUString BACKSLASH (RTL_CONSTASCII_USTRINGPARAM("\\")); +const rtl::OUString SLASH (RTL_CONSTASCII_USTRINGPARAM("/")); /******************************************************************* osl_systemPathEnsureSeparator @@ -116,3 +117,4 @@ sal_Int32 osl_systemPathIsLogicalDrivePattern(/*in*/ const rtl_uString* pustrPat } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/path_helper.h b/sal/osl/w32/path_helper.h index df40758e9..41a0f4330 100644 --- a/sal/osl/w32/path_helper.h +++ b/sal/osl/w32/path_helper.h @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -68,3 +69,5 @@ sal_Int32 osl_systemPathIsLogicalDrivePattern(/*in*/ const rtl_uString* pustrPat #endif #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/path_helper.hxx b/sal/osl/w32/path_helper.hxx index 690129245..f7f464650 100644 --- a/sal/osl/w32/path_helper.hxx +++ b/sal/osl/w32/path_helper.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -116,3 +117,5 @@ public: } // end namespace osl #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/pipe.c b/sal/osl/w32/pipe.c index ab8421b61..3d00aa26c 100644 --- a/sal/osl/w32/pipe.c +++ b/sal/osl/w32/pipe.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,8 +28,6 @@ #include "system.h" -#include "pipeimpl.h" - #include <osl/pipe.h> #include <osl/diagnose.h> #include <osl/thread.h> @@ -138,7 +137,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options rtl_uString_newFromAscii(&path, PIPESYSTEM); rtl_uString_newFromAscii(&name, PIPEPREFIX); - if ( /*IS_NT &&*/ Security) + if ( Security) { rtl_uString *Ident = NULL; rtl_uString *Delim = NULL; @@ -188,20 +187,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options { SetLastError( ERROR_SUCCESS ); - if ( IS_NT ) - pPipe->m_NamedObject = CreateMutexW( NULL, FALSE, name->buffer ); - else - { - LPSTR pszTempBuffer = NULL; - int nCharsNeeded; - - nCharsNeeded = WideCharToMultiByte( CP_ACP, 0, name->buffer, name->length, NULL, 0, NULL, NULL ); - pszTempBuffer = alloca( nCharsNeeded * sizeof(CHAR) ); - nCharsNeeded = WideCharToMultiByte( CP_ACP, 0, name->buffer, name->length, pszTempBuffer, nCharsNeeded, NULL, NULL ); - pszTempBuffer[nCharsNeeded-1] = 0; - - pPipe->m_NamedObject = CreateMutexA( NULL, FALSE, pszTempBuffer ); - } + pPipe->m_NamedObject = CreateMutexW( NULL, FALSE, name->buffer ); if ( pPipe->m_NamedObject != INVALID_HANDLE_VALUE && pPipe->m_NamedObject != NULL ) { @@ -210,45 +196,22 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options pPipe->m_Security = pSecAttr; rtl_uString_assign(&pPipe->m_Name, name); - if (IS_NT) + /* try to open system pipe */ + pPipe->m_File = CreateNamedPipeW( + path->buffer, + PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, + PIPE_WAIT | PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, + PIPE_UNLIMITED_INSTANCES, + 4096, 4096, + NMPWAIT_WAIT_FOREVER, + pPipe->m_Security); + + if (pPipe->m_File != INVALID_HANDLE_VALUE) { - /* try to open system pipe */ - pPipe->m_File = CreateNamedPipeW( - path->buffer, - PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, - PIPE_WAIT | PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, - PIPE_UNLIMITED_INSTANCES, - 4096, 4096, - NMPWAIT_WAIT_FOREVER, - pPipe->m_Security); - - if (pPipe->m_File != INVALID_HANDLE_VALUE) - { - rtl_uString_release( name ); - rtl_uString_release( path ); + rtl_uString_release( name ); + rtl_uString_release( path ); - return pPipe; - } - } - else /* Win 9x */ - { - LPSTR pszTempBuffer = NULL; - int nCharsNeeded; - - nCharsNeeded = WideCharToMultiByte( CP_ACP, 0, path->buffer, path->length, NULL, 0, NULL, NULL ); - pszTempBuffer = alloca( nCharsNeeded * sizeof(CHAR) ); - nCharsNeeded = WideCharToMultiByte( CP_ACP, 0, path->buffer, path->length, pszTempBuffer, nCharsNeeded, NULL, NULL ); - pszTempBuffer[nCharsNeeded-1] = 0; - - pPipe->m_File = CreateSimplePipe( pszTempBuffer ); - - if ( IsValidHandle(pPipe->m_File) ) - { - rtl_uString_release( name ); - rtl_uString_release( path ); - - return pPipe; - } + return pPipe; } } else @@ -260,63 +223,39 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options } else { - if (IS_NT) + BOOL fPipeAvailable; + + do { - BOOL fPipeAvailable; + /* free instance should be available first */ + fPipeAvailable = WaitNamedPipeW(path->buffer, NMPWAIT_WAIT_FOREVER); - do + /* first try to open system pipe */ + if ( fPipeAvailable ) { - /* free instance should be available first */ - fPipeAvailable = WaitNamedPipeW(path->buffer, NMPWAIT_WAIT_FOREVER); - - /* first try to open system pipe */ - if ( fPipeAvailable ) + pPipe->m_File = CreateFileW( + path->buffer, + GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, + NULL); + + if ( pPipe->m_File != INVALID_HANDLE_VALUE ) { - pPipe->m_File = CreateFileW( - path->buffer, - GENERIC_READ|GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, - NULL); - - if ( pPipe->m_File != INVALID_HANDLE_VALUE ) - { - // We got it ! - rtl_uString_release( name ); - rtl_uString_release( path ); + // We got it ! + rtl_uString_release( name ); + rtl_uString_release( path ); - return (pPipe); - } - else - { - // Pipe instance maybe catched by another client -> try again - } + return (pPipe); + } + else + { + // Pipe instance maybe catched by another client -> try again } - } while ( fPipeAvailable ); - } - else /* Win 9x */ - { - LPSTR pszTempBuffer = NULL; - int nCharsNeeded; - - nCharsNeeded = WideCharToMultiByte( CP_ACP, 0, path->buffer, path->length, NULL, 0, NULL, NULL ); - pszTempBuffer = alloca( nCharsNeeded * sizeof(CHAR) ); - nCharsNeeded = WideCharToMultiByte( CP_ACP, 0, path->buffer, path->length, pszTempBuffer, nCharsNeeded, NULL, NULL ); - pszTempBuffer[nCharsNeeded-1] = 0; - - pPipe->m_File = OpenSimplePipe( pszTempBuffer ); - - if ( IsValidHandle(pPipe->m_File) ) - { - // We got it ! - rtl_uString_release( name ); - rtl_uString_release( path ); - - return (pPipe); } - } + } while ( fPipeAvailable ); } /* if we reach here something went wrong */ @@ -351,21 +290,13 @@ void SAL_CALL osl_closePipe( oslPipe pPipe ) if( pPipe && ! pPipe->m_bClosed ) { pPipe->m_bClosed = sal_True; - if (IS_NT) + /* if we have a system pipe close it */ + if (pPipe->m_File != INVALID_HANDLE_VALUE) { - /* if we have a system pipe close it */ - if (pPipe->m_File != INVALID_HANDLE_VALUE) - { - /* FlushFileBuffers(pPipe->m_File); */ - DisconnectNamedPipe(pPipe->m_File); - CloseHandle(pPipe->m_File); - } - } - else - { - CloseSimplePipe( pPipe->m_File ); + /* FlushFileBuffers(pPipe->m_File); */ + DisconnectNamedPipe(pPipe->m_File); + CloseHandle(pPipe->m_File); } - } } @@ -379,25 +310,23 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe) HANDLE Event; OVERLAPPED os; - OSL_ASSERT(pPipe); + DWORD nBytesTransfered; + rtl_uString* path = NULL; + rtl_uString* temp = NULL; - if (IS_NT) - { - DWORD nBytesTransfered; - rtl_uString* path = NULL; - rtl_uString* temp = NULL; + OSL_ASSERT(pPipe); - OSL_ASSERT (pPipe->m_File != INVALID_HANDLE_VALUE); + OSL_ASSERT (pPipe->m_File != INVALID_HANDLE_VALUE); - Event = pPipe->m_AcceptEvent; - rtl_zeroMemory(&os, sizeof(OVERLAPPED)); - os.hEvent = pPipe->m_AcceptEvent; - ResetEvent(pPipe->m_AcceptEvent); + Event = pPipe->m_AcceptEvent; + rtl_zeroMemory(&os, sizeof(OVERLAPPED)); + os.hEvent = pPipe->m_AcceptEvent; + ResetEvent(pPipe->m_AcceptEvent); - if ( !ConnectNamedPipe(pPipe->m_File, &os)) + if ( !ConnectNamedPipe(pPipe->m_File, &os)) + { + switch ( GetLastError() ) { - switch ( GetLastError() ) - { case ERROR_PIPE_CONNECTED: // Client already connected to pipe case ERROR_NO_DATA: // Client was connected but has already closed pipe end // should only appear in nonblocking mode but in fact does @@ -425,43 +354,30 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe) break; default: // All other error say that somethings going wrong. return 0; - } } - - - pAcceptedPipe = __osl_createPipeImpl(); - OSL_ASSERT(pAcceptedPipe); - - osl_incrementInterlockedCount(&(pAcceptedPipe->m_Reference)); - rtl_uString_assign(&pAcceptedPipe->m_Name, pPipe->m_Name); - pAcceptedPipe->m_File = pPipe->m_File; - - rtl_uString_newFromAscii(&temp, PIPESYSTEM); - rtl_uString_newConcat(&path, temp, pPipe->m_Name); - rtl_uString_release(temp); - - // prepare for next accept - pPipe->m_File = - CreateNamedPipeW(path->buffer, - PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, - PIPE_WAIT | PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, - PIPE_UNLIMITED_INSTANCES, - 4096, 4096, - NMPWAIT_WAIT_FOREVER, - pAcceptedPipe->m_Security); - rtl_uString_release( path ); } - else /* Win9x */ - { - pAcceptedPipe = __osl_createPipeImpl(); - OSL_ASSERT(pAcceptedPipe); - osl_incrementInterlockedCount(&(pAcceptedPipe->m_Reference)); - rtl_uString_assign(&pAcceptedPipe->m_Name, pPipe->m_Name); - pAcceptedPipe->m_File = pPipe->m_File; + pAcceptedPipe = __osl_createPipeImpl(); + OSL_ASSERT(pAcceptedPipe); - pAcceptedPipe->m_File = AcceptSimplePipeConnection( pPipe->m_File ); - } + osl_incrementInterlockedCount(&(pAcceptedPipe->m_Reference)); + rtl_uString_assign(&pAcceptedPipe->m_Name, pPipe->m_Name); + pAcceptedPipe->m_File = pPipe->m_File; + + rtl_uString_newFromAscii(&temp, PIPESYSTEM); + rtl_uString_newConcat(&path, temp, pPipe->m_Name); + rtl_uString_release(temp); + + // prepare for next accept + pPipe->m_File = + CreateNamedPipeW(path->buffer, + PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, + PIPE_WAIT | PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, + PIPE_UNLIMITED_INSTANCES, + 4096, 4096, + NMPWAIT_WAIT_FOREVER, + pAcceptedPipe->m_Security); + rtl_uString_release( path ); return pAcceptedPipe; } @@ -474,47 +390,32 @@ sal_Int32 SAL_CALL osl_receivePipe(oslPipe pPipe, sal_Int32 BytesToRead) { DWORD nBytes; + OVERLAPPED os; OSL_ASSERT(pPipe); - /* if we have a system pipe use it */ - if ( IS_NT /*pPipe->m_File != INVALID_HANDLE_VALUE*/) - { - OVERLAPPED os; - rtl_zeroMemory(&os,sizeof(OVERLAPPED)); - os.hEvent = pPipe->m_ReadEvent; + rtl_zeroMemory(&os,sizeof(OVERLAPPED)); + os.hEvent = pPipe->m_ReadEvent; - ResetEvent(pPipe->m_ReadEvent); - - if (! ReadFile(pPipe->m_File, pBuffer, BytesToRead, &nBytes, &os) && - ((GetLastError() != ERROR_IO_PENDING) || - ! GetOverlappedResult(pPipe->m_File, &os, &nBytes, TRUE))) - { - DWORD lastError = GetLastError(); - - if (lastError == ERROR_MORE_DATA) - nBytes = BytesToRead; - else - { - if (lastError == ERROR_PIPE_NOT_CONNECTED) - nBytes = 0; - else - nBytes = (DWORD) -1; - - pPipe->m_Error = osl_Pipe_E_ConnectionAbort; - } - } - } - else + ResetEvent(pPipe->m_ReadEvent); + + if (! ReadFile(pPipe->m_File, pBuffer, BytesToRead, &nBytes, &os) && + ((GetLastError() != ERROR_IO_PENDING) || + ! GetOverlappedResult(pPipe->m_File, &os, &nBytes, TRUE))) { - BOOL fSuccess = ReadSimplePipe( pPipe->m_File, pBuffer, BytesToRead, &nBytes, TRUE ); + DWORD lastError = GetLastError(); + + if (lastError == ERROR_MORE_DATA) + nBytes = BytesToRead; + else + { + if (lastError == ERROR_PIPE_NOT_CONNECTED) + nBytes = 0; + else + nBytes = (DWORD) -1; - if ( !fSuccess ) - { - nBytes = 0; pPipe->m_Error = osl_Pipe_E_ConnectionAbort; } - } return (nBytes); @@ -528,36 +429,24 @@ sal_Int32 SAL_CALL osl_sendPipe(oslPipe pPipe, sal_Int32 BytesToSend) { DWORD nBytes; + OVERLAPPED os; + OSL_ASSERT(pPipe); - if (IS_NT/*pPipe->m_File != INVALID_HANDLE_VALUE*/) - { - OVERLAPPED os; - rtl_zeroMemory(&os, sizeof(OVERLAPPED)); - os.hEvent = pPipe->m_WriteEvent; - ResetEvent(pPipe->m_WriteEvent); - - if (! WriteFile(pPipe->m_File, pBuffer, BytesToSend, &nBytes, &os) && - ((GetLastError() != ERROR_IO_PENDING) || - ! GetOverlappedResult(pPipe->m_File, &os, &nBytes, TRUE))) - { - if (GetLastError() == ERROR_PIPE_NOT_CONNECTED) - nBytes = 0; - else - nBytes = (DWORD) -1; + rtl_zeroMemory(&os, sizeof(OVERLAPPED)); + os.hEvent = pPipe->m_WriteEvent; + ResetEvent(pPipe->m_WriteEvent); - pPipe->m_Error = osl_Pipe_E_ConnectionAbort; - } - } - else + if (! WriteFile(pPipe->m_File, pBuffer, BytesToSend, &nBytes, &os) && + ((GetLastError() != ERROR_IO_PENDING) || + ! GetOverlappedResult(pPipe->m_File, &os, &nBytes, TRUE))) { - BOOL fSuccess = WriteSimplePipe( pPipe->m_File, pBuffer, BytesToSend, &nBytes, TRUE ); - - if ( !fSuccess ) - { + if (GetLastError() == ERROR_PIPE_NOT_CONNECTED) nBytes = 0; - pPipe->m_Error = osl_Pipe_E_ConnectionAbort; - } + else + nBytes = (DWORD) -1; + + pPipe->m_Error = osl_Pipe_E_ConnectionAbort; } return (nBytes); @@ -565,7 +454,7 @@ sal_Int32 SAL_CALL osl_sendPipe(oslPipe pPipe, sal_Int32 SAL_CALL osl_writePipe( oslPipe pPipe, const void *pBuffer , sal_Int32 n ) { - /* loop until all desired bytes were send or an error occured */ + /* loop until all desired bytes were send or an error occurred */ sal_Int32 BytesSend= 0; sal_Int32 BytesToSend= n; @@ -576,7 +465,7 @@ sal_Int32 SAL_CALL osl_writePipe( oslPipe pPipe, const void *pBuffer , sal_Int32 RetVal= osl_sendPipe(pPipe, pBuffer, BytesToSend); - /* error occured? */ + /* error occurred? */ if(RetVal <= 0) { break; @@ -592,7 +481,7 @@ sal_Int32 SAL_CALL osl_writePipe( oslPipe pPipe, const void *pBuffer , sal_Int32 sal_Int32 SAL_CALL osl_readPipe( oslPipe pPipe, void *pBuffer , sal_Int32 n ) { - /* loop until all desired bytes were read or an error occured */ + /* loop until all desired bytes were read or an error occurred */ sal_Int32 BytesRead= 0; sal_Int32 BytesToRead= n; @@ -602,7 +491,7 @@ sal_Int32 SAL_CALL osl_readPipe( oslPipe pPipe, void *pBuffer , sal_Int32 n ) sal_Int32 RetVal; RetVal= osl_receivePipe(pPipe, pBuffer, BytesToRead); - /* error occured? */ + /* error occurred? */ if(RetVal <= 0) { break; @@ -634,3 +523,4 @@ oslPipeError SAL_CALL osl_getLastPipeError(oslPipe pPipe) return (Error); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/pipeimpl.cxx b/sal/osl/w32/pipeimpl.cxx deleted file mode 100644 index b5ecafd86..000000000 --- a/sal/osl/w32/pipeimpl.cxx +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sal.hxx" -# include "pipeimpl.h" - -#ifndef _INC_MALLOC -# include <malloc.h> -#endif - -#ifndef _INC_TCHAR -# ifdef UNICODE -# define _UNICODE -# endif -# include <tchar.h> -#endif - -const TCHAR PIPE_NAME_PREFIX_MAPPING[] = TEXT("PIPE_FILE_MAPPING_"); -const TCHAR PIPE_NAME_PREFIX_SYNCHRONIZE[] = TEXT("PIPE_SYNCHRONIZE_MUTEX_"); -const TCHAR PIPE_NAME_PREFIX_CONNECTION[] = TEXT("PIPE_CONNECTION_SEMAPHORE_"); - -const DWORD PIPE_BUFFER_SIZE = 4096; - - -//============================================================================ -// PipeData -//============================================================================ - -struct PipeData -{ - DWORD dwProcessId; - HANDLE hReadPipe; - HANDLE hWritePipe; -}; - -//============================================================================ -// Pipe -//============================================================================ - -#ifdef UNICODE -#define Pipe PipeW -#define ClientPipe ClientPipeW -#define ServerPipe ServerPipeW -#else -#define Pipe PipeA -#define ClientPipe ClientPipeA -#define ServerPipe ServerPipeA -#endif - -class Pipe -{ -protected: - HANDLE m_hReadPipe; // Handle to use for reading - HANDLE m_hWritePipe; // Handle to use for writing - - Pipe( HANDLE hReadPipe, HANDLE hWritePipe ); - - static HANDLE CreatePipeDataMutex( LPCTSTR lpName, BOOL bInitialOwner ); - static HANDLE CreatePipeDataMapping( LPCTSTR lpName ); - static HANDLE OpenPipeDataMapping( LPCTSTR lpName ); - static HANDLE CreatePipeConnectionSemaphore( LPCTSTR lpName, LONG lInitialCount, LONG lMaximumcount ); - -public: - Pipe( const Pipe& ); - const Pipe& operator = ( const Pipe& ); - virtual ~Pipe(); - - virtual bool Close(); - virtual bool Write( LPCVOID lpBuffer, DWORD dwBytesToWrite, LPDWORD lpBytesWritten, bool bWait = true ); - virtual bool Read( LPVOID lpBuffer, DWORD dwBytesToRead, LPDWORD lpBytesRead, bool bWait = true ); - - virtual Pipe *AcceptConnection() - { - SetLastError( ERROR_INVALID_HANDLE ); - return NULL; - } - - void * operator new( size_t nBytes ) - { - return HeapAlloc( GetProcessHeap(), 0, nBytes ); - } - - void operator delete( void *ptr ) - { - HeapFree( GetProcessHeap(), 0, ptr ); - } - - bool is() const - { - return (FALSE != HeapValidate( GetProcessHeap(), 0, this )); - } - -}; - -//============================================================================ -// ClientPipe -//============================================================================ - -class ClientPipe : public Pipe -{ -protected: - ClientPipe( HANDLE hReadPipe, HANDLE hWritePipe ); -public: - static ClientPipe* Create( LPCTSTR lpName ); -}; - -//============================================================================ -// ServerPipe -//============================================================================ - -class ServerPipe : public Pipe -{ -protected: - HANDLE m_hMapping; - HANDLE m_hSynchronize; - LPTSTR m_lpName; - - ServerPipe( LPCTSTR lpName, HANDLE hMapping, HANDLE hSynchronize, HANDLE hReadPipe, HANDLE hWritePipe ); -public: - virtual ~ServerPipe(); - - static ServerPipe *Create( LPCTSTR lpName ); - - virtual Pipe *AcceptConnection(); -}; - -//---------------------------------------------------------------------------- -// -//---------------------------------------------------------------------------- - -HANDLE Pipe::CreatePipeDataMapping( LPCTSTR lpName ) -{ - HANDLE hMapping = NULL; - LPTSTR lpMappingName = (LPTSTR)alloca( _tcslen(lpName) * sizeof(TCHAR) + sizeof(PIPE_NAME_PREFIX_MAPPING) ); - - if ( lpMappingName ) - { - _tcscpy( lpMappingName, PIPE_NAME_PREFIX_MAPPING ); - _tcscat( lpMappingName, lpName ); - - LPTSTR lpMappingFileName = (LPTSTR)alloca( MAX_PATH * sizeof(TCHAR) ); - - if ( lpMappingFileName ) - { - DWORD nChars = GetTempPath( MAX_PATH, lpMappingFileName ); - - if ( MAX_PATH + _tcslen(lpName) < nChars + 1 ) - { - lpMappingFileName = (LPTSTR)alloca( (nChars + 1 + _tcslen(lpName)) * sizeof(TCHAR) ); - if ( lpMappingFileName ) - nChars = GetTempPath( nChars, lpMappingFileName ); - else - { - nChars = 0; - SetLastError( ERROR_NOT_ENOUGH_MEMORY ); - } - } - - if ( nChars ) - { - _tcscat( lpMappingFileName, lpMappingName ); - - HANDLE hFile = CreateFile( - lpMappingFileName, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, - NULL ); - - if ( IsValidHandle(hFile) ) - { - hMapping = CreateFileMapping( - (HANDLE)hFile, - (LPSECURITY_ATTRIBUTES)NULL, - PAGE_READWRITE, - 0, - sizeof(PipeData), - lpMappingName ); - - CloseHandle( hFile ); - } - } - } - else - SetLastError( ERROR_NOT_ENOUGH_MEMORY ); - } - - return hMapping; -} - -//---------------------------------------------------------------------------- -// -//---------------------------------------------------------------------------- - -HANDLE Pipe::OpenPipeDataMapping( LPCTSTR lpName ) -{ - HANDLE hMapping = NULL; - LPTSTR lpMappingName = (LPTSTR)alloca( _tcslen(lpName) * sizeof(TCHAR) + sizeof(PIPE_NAME_PREFIX_MAPPING) ); - - if ( lpMappingName ) - { - _tcscpy( lpMappingName, PIPE_NAME_PREFIX_MAPPING ); - _tcscat( lpMappingName, lpName ); - - hMapping = OpenFileMapping( FILE_MAP_ALL_ACCESS, FALSE, lpMappingName ); - } - - return hMapping; -} - -//---------------------------------------------------------------------------- -// -//---------------------------------------------------------------------------- - -HANDLE Pipe::CreatePipeDataMutex( LPCTSTR lpName, BOOL bInitialOwner ) -{ - HANDLE hMutex = NULL; - LPTSTR lpMutexName = (LPTSTR)alloca( _tcslen(lpName) * sizeof(TCHAR) + sizeof(PIPE_NAME_PREFIX_SYNCHRONIZE) ); - - if ( lpMutexName ) - { - _tcscpy( lpMutexName, PIPE_NAME_PREFIX_SYNCHRONIZE ); - _tcscat( lpMutexName, lpName ); - - hMutex = CreateMutex( NULL, bInitialOwner, lpMutexName ); - } - - return hMutex; -} - -//---------------------------------------------------------------------------- -// -//---------------------------------------------------------------------------- - -HANDLE Pipe::CreatePipeConnectionSemaphore( LPCTSTR lpName, LONG lInitialCount, LONG lMaximumCount ) -{ - HANDLE hSemaphore = NULL; - LPTSTR lpSemaphoreName = (LPTSTR)alloca( _tcslen(lpName) * sizeof(TCHAR) + sizeof(PIPE_NAME_PREFIX_CONNECTION) ); - - if ( lpSemaphoreName ) - { - _tcscpy( lpSemaphoreName, PIPE_NAME_PREFIX_CONNECTION ); - _tcscat( lpSemaphoreName, lpName ); - - hSemaphore = CreateSemaphore( NULL, lInitialCount, lMaximumCount, lpSemaphoreName ); - } - - return hSemaphore; -} - - -//---------------------------------------------------------------------------- -// Pipe copy ctor -//---------------------------------------------------------------------------- - -Pipe::Pipe( const Pipe& rPipe ) : -m_hReadPipe( INVALID_HANDLE_VALUE ), -m_hWritePipe( INVALID_HANDLE_VALUE ) -{ - DuplicateHandle( - GetCurrentProcess(), - rPipe.m_hReadPipe, - GetCurrentProcess(), - &m_hReadPipe, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ); - - DuplicateHandle( - GetCurrentProcess(), - rPipe.m_hWritePipe, - GetCurrentProcess(), - &m_hWritePipe, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ); -} - -//---------------------------------------------------------------------------- -// Pipe assignment operator -//---------------------------------------------------------------------------- - -const Pipe& Pipe::operator = ( const Pipe& rPipe ) -{ - Close(); - - DuplicateHandle( - GetCurrentProcess(), - rPipe.m_hReadPipe, - GetCurrentProcess(), - &m_hReadPipe, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ); - - DuplicateHandle( - GetCurrentProcess(), - rPipe.m_hWritePipe, - GetCurrentProcess(), - &m_hWritePipe, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ); - - return *this; -} - -//---------------------------------------------------------------------------- -// Pipe ctor -//---------------------------------------------------------------------------- - -Pipe::Pipe( HANDLE hReadPipe, HANDLE hWritePipe ) : -m_hReadPipe( INVALID_HANDLE_VALUE ), -m_hWritePipe( INVALID_HANDLE_VALUE ) -{ - DuplicateHandle( - GetCurrentProcess(), - hReadPipe, - GetCurrentProcess(), - &m_hReadPipe, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ); - - DuplicateHandle( - GetCurrentProcess(), - hWritePipe, - GetCurrentProcess(), - &m_hWritePipe, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ); -} - -//---------------------------------------------------------------------------- -// Pipe dtor -//---------------------------------------------------------------------------- - -Pipe::~Pipe() -{ - Close(); -} - -//---------------------------------------------------------------------------- -// Pipe Close -//---------------------------------------------------------------------------- - -bool Pipe::Close() -{ - bool fSuccess = false; // Assume failure - - if ( IsValidHandle(m_hReadPipe) ) - { - CloseHandle( m_hReadPipe ); - m_hReadPipe = INVALID_HANDLE_VALUE; - } - - if ( IsValidHandle(m_hWritePipe) ) - { - CloseHandle( m_hWritePipe ); - m_hWritePipe = INVALID_HANDLE_VALUE; - } - - return fSuccess; -} - -//---------------------------------------------------------------------------- -// Pipe Write -//---------------------------------------------------------------------------- - -bool Pipe::Write( LPCVOID lpBuffer, DWORD dwBytesToWrite, LPDWORD lpBytesWritten, bool bWait ) -{ - DWORD dwBytesAvailable = 0; - BOOL fSuccess = TRUE; - - if ( !bWait ) - fSuccess = PeekNamedPipe( m_hReadPipe, NULL, 0, NULL, &dwBytesAvailable, NULL ); - - if ( fSuccess ) - { - if ( !bWait && dwBytesToWrite > PIPE_BUFFER_SIZE - dwBytesAvailable ) - dwBytesToWrite = PIPE_BUFFER_SIZE - dwBytesAvailable ; - - return !!WriteFile( m_hWritePipe, lpBuffer, dwBytesToWrite, lpBytesWritten, NULL ); - } - - return false; -} - -//---------------------------------------------------------------------------- -// Pipe Read -//---------------------------------------------------------------------------- - -bool Pipe::Read( LPVOID lpBuffer, DWORD dwBytesToRead, LPDWORD lpBytesRead, bool bWait ) -{ - DWORD dwBytesAvailable = 0; - BOOL fSuccess = TRUE; - - if ( !bWait ) - fSuccess = PeekNamedPipe( m_hReadPipe, NULL, 0, NULL, &dwBytesAvailable, NULL ); - - if ( fSuccess ) - { - if ( bWait || dwBytesAvailable ) - return !!ReadFile( m_hReadPipe, lpBuffer, dwBytesToRead, lpBytesRead, NULL ); - else - { - *lpBytesRead = 0; - return true; - } - } - - return false; -} - - - -//---------------------------------------------------------------------------- -// Client pipe dtor -//---------------------------------------------------------------------------- - -ClientPipe::ClientPipe( HANDLE hReadPipe, HANDLE hWritePipe ) : Pipe( hReadPipe, hWritePipe ) -{ -} - -//---------------------------------------------------------------------------- -// Client pipe creation -//---------------------------------------------------------------------------- - -ClientPipe *ClientPipe::Create( LPCTSTR lpName ) -{ - ClientPipe *pPipe = NULL; // Assume failure - - HANDLE hMapping = OpenPipeDataMapping( lpName ); - - if ( IsValidHandle(hMapping) ) - { - PipeData *pData = (PipeData*)MapViewOfFile( hMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0 ); - - if ( pData ) - { - HANDLE hSourceProcess = OpenProcess( PROCESS_DUP_HANDLE, FALSE, pData->dwProcessId ); - - if ( IsValidHandle(hSourceProcess) ) - { - BOOL fSuccess; - HANDLE hReadPipe = INVALID_HANDLE_VALUE, hWritePipe = INVALID_HANDLE_VALUE; - - fSuccess = DuplicateHandle( - hSourceProcess, - pData->hReadPipe, - GetCurrentProcess(), - &hReadPipe, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ); - - fSuccess = fSuccess && DuplicateHandle( - hSourceProcess, - pData->hWritePipe, - GetCurrentProcess(), - &hWritePipe, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ); - - if ( fSuccess ) - pPipe = new ClientPipe( hReadPipe, hWritePipe ); - - if ( IsValidHandle(hWritePipe) ) - CloseHandle( hWritePipe ); - - if ( IsValidHandle(hReadPipe) ) - CloseHandle( hReadPipe ); - - HANDLE hConnectionRequest = CreatePipeConnectionSemaphore( lpName, 0, 1 ); - - ReleaseSemaphore( hConnectionRequest, 1, NULL ); - - CloseHandle( hConnectionRequest ); - - CloseHandle( hSourceProcess ); - } - - UnmapViewOfFile( pData ); - } - - CloseHandle( hMapping ); - } - - return pPipe; -} - - - -//---------------------------------------------------------------------------- -// ServerPipe ctor -//---------------------------------------------------------------------------- - -ServerPipe::ServerPipe( LPCTSTR lpName, HANDLE hMapping, HANDLE hSynchronize, HANDLE hReadPipe, HANDLE hWritePipe ) : Pipe( hReadPipe, hWritePipe ), -m_hMapping( NULL ), -m_hSynchronize( NULL ), -m_lpName( NULL ) -{ - DuplicateHandle( - GetCurrentProcess(), - hMapping, - GetCurrentProcess(), - &m_hMapping, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ); - - DuplicateHandle( - GetCurrentProcess(), - hSynchronize, - GetCurrentProcess(), - &m_hSynchronize, - 0, - FALSE, - DUPLICATE_SAME_ACCESS - ); - m_lpName = new TCHAR[_tcslen(lpName) + 1]; - if ( m_lpName ) - _tcscpy( m_lpName, lpName ); -} - -//---------------------------------------------------------------------------- -// ServerPipe dtor -//---------------------------------------------------------------------------- - -ServerPipe::~ServerPipe() -{ - if ( IsValidHandle(m_hMapping) ) - CloseHandle( m_hMapping ); - if ( m_lpName ) - delete[]m_lpName; -} - -//---------------------------------------------------------------------------- -// ServerPipe AcceptConnection -//---------------------------------------------------------------------------- - -Pipe *ServerPipe::AcceptConnection() -{ - Pipe *pPipe = NULL; // Assume failure; - - HANDLE hConnectionRequest = CreatePipeConnectionSemaphore( m_lpName, 0, 1 ); - - if ( WAIT_OBJECT_0 == WaitForSingleObject( hConnectionRequest, INFINITE ) ) - { - pPipe = new Pipe( *this ); - Close(); - - // Create new inbound Pipe - - HANDLE hClientWritePipe = NULL, hServerReadPipe = NULL; - - BOOL fSuccess = CreatePipe( &hServerReadPipe, &hClientWritePipe, NULL, PIPE_BUFFER_SIZE ); - - - if ( fSuccess ) - { - // Create outbound pipe - - HANDLE hClientReadPipe = NULL, hServerWritePipe = NULL; - - if ( CreatePipe( &hClientReadPipe, &hServerWritePipe, NULL, PIPE_BUFFER_SIZE ) ) - { - m_hReadPipe = hServerReadPipe; - m_hWritePipe = hServerWritePipe; - - PipeData *pData = (PipeData *)MapViewOfFile( m_hMapping, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(PipeData) ); - - HANDLE hSynchronize = CreatePipeDataMutex( m_lpName, TRUE ); - - CloseHandle( pData->hReadPipe ); - CloseHandle( pData->hWritePipe ); - - pData->hReadPipe = hClientReadPipe; - pData->hWritePipe = hClientWritePipe; - - ReleaseMutex( hSynchronize ); - - CloseHandle( hSynchronize ); - - } - else - { - CloseHandle( hClientWritePipe ); - CloseHandle( hServerWritePipe ); - } - } - - ReleaseMutex( hConnectionRequest ); - } - - CloseHandle( hConnectionRequest ); - - return pPipe; -} - -//---------------------------------------------------------------------------- -// Pipe creation -//---------------------------------------------------------------------------- - -ServerPipe *ServerPipe::Create( LPCTSTR lpName ) -{ - ServerPipe *pPipe = NULL; - - HANDLE hMapping = CreatePipeDataMapping( lpName ); - - if ( IsValidHandle(hMapping) ) - { - if ( ERROR_FILE_EXISTS != GetLastError() ) - { - HANDLE hSynchronize = CreatePipeDataMutex( lpName, FALSE); - - WaitForSingleObject( hSynchronize, INFINITE ); - - PipeData *pData = (PipeData*)MapViewOfFile( hMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0 ); - - if ( pData ) - { - - // Initialize pipe data - - pData->dwProcessId = 0; - pData->hReadPipe = NULL; - pData->hWritePipe = NULL; - - // Create inbound pipe - - HANDLE hServerReadPipe = NULL, hClientWritePipe = NULL; - - BOOL fSuccess = CreatePipe( &hServerReadPipe, &hClientWritePipe, NULL, PIPE_BUFFER_SIZE ); - - if ( fSuccess ) - { - // Create outbound pipe - - HANDLE hServerWritePipe = NULL, hClientReadPipe = NULL; - - fSuccess = CreatePipe( &hClientReadPipe, &hServerWritePipe, NULL, PIPE_BUFFER_SIZE ); - - if ( fSuccess ) - { - pData->dwProcessId = GetCurrentProcessId(); - pData->hReadPipe = hClientReadPipe; - pData->hWritePipe = hClientWritePipe; - pPipe = new ServerPipe( lpName, hMapping, hSynchronize, hServerReadPipe, hServerWritePipe ); - - CloseHandle( hServerWritePipe ); - CloseHandle( hServerReadPipe ); - } - else - { - CloseHandle( hServerReadPipe ); - CloseHandle( hClientWritePipe ); - } - } - - UnmapViewOfFile( pData ); - } - - ReleaseMutex( hSynchronize ); - CloseHandle( hSynchronize ); - } - - CloseHandle( hMapping ); - } - - return pPipe; -} - - -//---------------------------------------------------------------------------- -// C style API -//---------------------------------------------------------------------------- - -const TCHAR LOCAL_PIPE_PREFIX[] = TEXT("\\\\.\\PIPE\\" ); - -extern "C" HANDLE WINAPI CreateSimplePipe( LPCTSTR lpName ) -{ - int nPrefixLen = _tcslen( LOCAL_PIPE_PREFIX ); - if ( 0 == _tcsnicmp( lpName, LOCAL_PIPE_PREFIX, nPrefixLen ) ) - lpName += nPrefixLen; - return (HANDLE)ServerPipe::Create( lpName ); -} - -extern "C" HANDLE WINAPI OpenSimplePipe( LPCTSTR lpName ) -{ - int nPrefixLen = _tcslen( LOCAL_PIPE_PREFIX ); - if ( 0 == _tcsnicmp( lpName, LOCAL_PIPE_PREFIX, nPrefixLen ) ) - lpName += nPrefixLen; - return (HANDLE)ClientPipe::Create( lpName ); -} - -extern "C" HANDLE WINAPI AcceptSimplePipeConnection( HANDLE hPipe ) -{ - Pipe *pPipe = (Pipe *)hPipe; - - if ( pPipe->is() ) - return (HANDLE)pPipe->AcceptConnection(); - else - { - SetLastError( ERROR_INVALID_HANDLE ); - return NULL; - } -} - -extern "C" BOOL WINAPI WaitForSimplePipe( LPCTSTR /*lpName*/, DWORD /*dwTimeOut*/ ) -{ - return FALSE; -} - -extern "C" BOOL WINAPI WriteSimplePipe( HANDLE hPipe, LPCVOID lpBuffer, DWORD dwBytesToWrite, LPDWORD lpBytesWritten, BOOL bWait ) -{ - Pipe *pPipe = (Pipe *)hPipe; - - if ( pPipe->is() ) - return pPipe->Write( lpBuffer, dwBytesToWrite, lpBytesWritten, bWait ); - else - { - SetLastError( ERROR_INVALID_HANDLE ); - return FALSE; - } -} - -extern "C" BOOL WINAPI ReadSimplePipe( HANDLE hPipe, LPVOID lpBuffer, DWORD dwBytesToRead, LPDWORD lpBytesRead, BOOL bWait ) -{ - Pipe *pPipe = (Pipe *)hPipe; - - if ( pPipe->is() ) - return pPipe->Read( lpBuffer, dwBytesToRead, lpBytesRead, bWait ); - else - { - SetLastError( ERROR_INVALID_HANDLE ); - return FALSE; - } -} - -extern "C" BOOL WINAPI CloseSimplePipe( HANDLE hPipe ) -{ - Pipe *pPipe = (Pipe *)hPipe; - - if ( pPipe->is() ) - { - delete pPipe; - return TRUE; - } - else - { - SetLastError( ERROR_INVALID_HANDLE ); - return FALSE; - } -} diff --git a/sal/osl/w32/pipeimpl.h b/sal/osl/w32/pipeimpl.h deleted file mode 100644 index cff98b9eb..000000000 --- a/sal/osl/w32/pipeimpl.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef _PIPEIMPL_H_ -#define _PIPEIMPL_H_ - -#ifndef _WINDOWS_ -# ifdef _MSC_VER -# pragma warning(push,1) /* disable warnings within system headers */ -# endif -# include <windows.h> -# ifdef _MSC_VER -# pragma warning(pop) -# endif -#endif - -#ifndef _INC_MALLOC -# include <malloc.h> -#endif - -#ifndef _INC_TCHAR -# ifdef UNICODE -# define _UNICODE -# endif -# include <tchar.h> -#endif - -#define EXPORT_PIPE_API - -//============================================================================ -// Helper functions -//============================================================================ - -// Because the value of an invalid HANDLE returned by API functions differs -// between different functions and differs on different Windows platforms, -// this function checks wether the handle has a meaningfull value. -#ifndef __cplusplus - -#define IsValidHandle( handle ) ((DWORD)(handle) + 1 > 1) - -#else - -inline bool IsValidHandle( HANDLE handle ) -{ - return INVALID_HANDLE_VALUE != handle && NULL != handle; -} - -extern "C" { - -#endif // __cplusplus - - -EXPORT_PIPE_API HANDLE WINAPI CreateSimplePipeA( LPCSTR lpName ); -EXPORT_PIPE_API HANDLE WINAPI CreateSimplePipeW( LPCWSTR lpName ); - -#ifdef UNICODE -#define CreateSimplePipe CreateSimplePipeW -#else -#define CreateSimplePipe CreateSimplePipeA -#endif - -EXPORT_PIPE_API HANDLE WINAPI OpenSimplePipeA( LPCSTR lpName ); -EXPORT_PIPE_API HANDLE WINAPI OpenSimplePipeW( LPCWSTR lpName ); - -#ifdef UNICODE -#define OpenSimplePipe OpenSimplePipeW -#else -#define OpenSimplePipe OpenSimplePipeA -#endif - -EXPORT_PIPE_API HANDLE WINAPI AcceptSimplePipeConnection( HANDLE hPipe ); - -EXPORT_PIPE_API BOOL WINAPI WaitForSimplePipeA( LPCSTR lpName, DWORD dwTimeOut ); -EXPORT_PIPE_API BOOL WINAPI WaitForSimplePipeW( LPCWSTR lpName, DWORD dwTimeOut ); - -#ifdef UNICODE -#define WaitForSimplePipe WaitForSimplePipeW -#else -#define WaitForSimplePipe WaitForSimplePipeA -#endif - - -EXPORT_PIPE_API BOOL WINAPI WriteSimplePipe( HANDLE hPipe, LPCVOID lpBuffer, DWORD dwBytesToWrite, LPDWORD lpBytesWritten, BOOL bWait ); -EXPORT_PIPE_API BOOL WINAPI ReadSimplePipe( HANDLE hPipe, LPVOID lpBuffer, DWORD dwBytesToRead, LPDWORD lpBytesRead, BOOL bWait ); -EXPORT_PIPE_API BOOL WINAPI CloseSimplePipe( HANDLE hPipe ); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PIPEIMPL_H_ diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx index 213a7bc1d..1749b8ec5 100644 --- a/sal/osl/w32/process.cxx +++ b/sal/osl/w32/process.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,6 +28,7 @@ #define UNICODE #include "system.h" +#include <string.h> #ifdef _MSC_VER #pragma warning(push,1) /* disable warnings within system headers */ #endif @@ -418,7 +420,15 @@ oslProcessError SAL_CALL osl_setEnvironment(rtl_uString *ustrVar, rtl_uString *u LPCWSTR lpName = reinterpret_cast<LPCWSTR>(ustrVar->buffer); LPCWSTR lpValue = reinterpret_cast<LPCWSTR>(ustrValue->buffer); if (SetEnvironmentVariableW(lpName, lpValue)) + { + wchar_t *buffer = new wchar_t[wcslen(lpName) + 1 + wcslen(lpValue) + 1]; + wcscpy(buffer, lpName); + wcscat(buffer, L"="); + wcscat(buffer, lpValue); + _wputenv(buffer); + delete[] buffer; return osl_Process_E_None; + } return osl_Process_E_Unknown; } @@ -428,7 +438,14 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString *ustrVar) //process's environment. LPCWSTR lpName = reinterpret_cast<LPCWSTR>(ustrVar->buffer); if (SetEnvironmentVariableW(lpName, NULL)) + { + wchar_t *buffer = new wchar_t[wcslen(lpName) + 1 + 1]; + wcscpy(buffer, lpName); + wcscat(buffer, L"="); + _wputenv(buffer); + delete[] buffer; return osl_Process_E_None; + } return osl_Process_E_Unknown; } @@ -637,3 +654,5 @@ oslSocket SAL_CALL osl_receiveResourcePipe(oslPipe hPipe) return pSocket; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/procimpl.cxx b/sal/osl/w32/procimpl.cxx index 4fad3f225..3ac82dcc9 100755..100644 --- a/sal/osl/w32/procimpl.cxx +++ b/sal/osl/w32/procimpl.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -61,8 +62,8 @@ extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle( HANDLE hFile //################################################# const sal_Unicode NAME_VALUE_SEPARATOR = TEXT('='); const sal_Char* SPACE = " "; -const rtl::OUString ENV_COMSPEC = rtl::OUString::createFromAscii("COMSPEC"); -const rtl::OUString QUOTE = rtl::OUString::createFromAscii("\""); +const rtl::OUString ENV_COMSPEC (RTL_CONSTASCII_USTRINGPARAM("COMSPEC")); +const rtl::OUString QUOTE(RTL_CONSTASCII_USTRINGPARAM("\"")); namespace /* private */ { @@ -314,7 +315,7 @@ namespace /* private */ std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec(path.getLength() + 1); //GetShortPathNameW only works if the file can be found! const DWORD len = GetShortPathNameW( - path.getStr(), &vec[0], path.getLength() + 1); + reinterpret_cast<LPCWSTR>(path.getStr()), reinterpret_cast<LPWSTR>(&vec[0]), path.getLength() + 1); if (!len && GetLastError() == ERROR_FILE_NOT_FOUND && extension.getLength()) @@ -323,7 +324,7 @@ namespace /* private */ std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec2( extPath.getLength() + 1); const DWORD len2 = GetShortPathNameW( - extPath.getStr(), &vec2[0], extPath.getLength() + 1); + reinterpret_cast<LPCWSTR>(extPath.getStr()), reinterpret_cast<LPWSTR>(&vec2[0]), extPath.getLength() + 1); ret = rtl::OUString(&vec2[0], len2); } else @@ -626,7 +627,7 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( } } - /* if an error occured we have to close the server side pipe ends too */ + /* if an error occurred we have to close the server side pipe ends too */ if (hInputWrite) CloseHandle(hInputWrite); @@ -639,3 +640,5 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( return osl_Process_E_Unknown; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/procimpl.h b/sal/osl/w32/procimpl.h index a174f6968..86a2ed04d 100644 --- a/sal/osl/w32/procimpl.h +++ b/sal/osl/w32/procimpl.h @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -45,3 +46,4 @@ typedef struct _oslProcessImpl { #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx index 0bda059dc..f06c41790 100644 --- a/sal/osl/w32/profile.cxx +++ b/sal/osl/w32/profile.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -36,6 +37,7 @@ #include <osl/file.h> #include <osl/util.h> #include <rtl/alloc.h> +#include <sal/macros.h> #include <algorithm> using std::min; static inline void copy_ustr_n( void *dest, const void *source, size_t length ) { rtl_copyMemory(dest, source, length*sizeof(sal_Unicode)); } @@ -1274,11 +1276,6 @@ static osl_TFile* openFileImpl(rtl_uString * strFileName, oslProfileOption Profi if (! bWriteable) { -#if 0 -//#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("opening '%s' read only\n",pszFilename); -#endif - pFile->m_Handle = CreateFileW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strFileName )), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -1506,10 +1503,6 @@ static sal_Bool putLine(osl_TFile* pFile, const sal_Char *pszLine) { unsigned int Len = strlen(pszLine); -#ifdef DEBUG_OSL_PROFILE - int strLen=0; -#endif - if ( pFile == 0 || pFile->m_Handle < 0 ) { return (sal_False); @@ -1542,19 +1535,13 @@ static sal_Bool putLine(osl_TFile* pFile, const sal_Char *pszLine) memcpy(pFile->m_pWriteBuf + ( pFile->m_nWriteBufLen - pFile->m_nWriteBufFree ),pszLine,Len+1); -#ifdef DEBUG_OSL_PROFILE - strLen = strlen(pFile->m_pWriteBuf); -#endif + pFile->m_pWriteBuf[pFile->m_nWriteBufLen - pFile->m_nWriteBufFree + Len]='\r'; pFile->m_pWriteBuf[pFile->m_nWriteBufLen - pFile->m_nWriteBufFree + Len + 1]='\n'; pFile->m_pWriteBuf[pFile->m_nWriteBufLen - pFile->m_nWriteBufFree + Len + 2]='\0'; pFile->m_nWriteBufFree-=Len+2; -#ifdef DEBUG_OSL_PROFILE -/* OSL_TRACE("File Buffer in _putLine '%s' '%i'(%i)\n",pFile->m_pWriteBuf,strlen(pFile->m_pWriteBuf),pFile->m_nWriteBufLen - pFile->m_nWriteBufFree);*/ -#endif - return (sal_True); } @@ -2560,7 +2547,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str int i = 0; pStr = aTmpPath + nPos; - for (i = 0; i < (sizeof(SubDirs) / sizeof(SubDirs[0])); i++) + for (i = 0; i < SAL_N_ELEMENTS(SubDirs); i++) if (strnicmp(pStr + 1, SubDirs[i], strlen(SubDirs[i])) == 0) { if ( *strPath == 0) @@ -2705,3 +2692,4 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/salinit.cxx b/sal/osl/w32/salinit.cxx index 43b7b8a16..60a71488f 100644 --- a/sal/osl/w32/salinit.cxx +++ b/sal/osl/w32/salinit.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -100,3 +101,5 @@ void SAL_CALL sal_detail_deinitialize() #ifdef __cplusplus } // extern "C" #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/secimpl.h b/sal/osl/w32/secimpl.h index ef437ca62..ccae39e96 100644 --- a/sal/osl/w32/secimpl.h +++ b/sal/osl/w32/secimpl.h @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -52,3 +53,4 @@ typedef struct _oslSecurityImpl { #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/security.c b/sal/osl/w32/security.c index 4d9ee324e..1f1e188ec 100644 --- a/sal/osl/w32/security.c +++ b/sal/osl/w32/security.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -33,6 +34,7 @@ #include <osl/thread.h> #include <osl/file.h> #include <systools/win32/uwinapi.h> +#include <sal/macros.h> #include "secimpl.h" /*****************************************************************************/ @@ -83,7 +85,6 @@ typedef BOOL (STDMETHODCALLTYPE FAR * LPFNGETUSERPROFILEDIR) ( /* Static Module Function Declarations */ /*****************************************************************************/ -static sal_Bool isWNT(void); static sal_Bool GetSpecialFolder(rtl_uString **strPath,int nFolder); static BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable); static sal_Bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **strName, sal_Bool bIncludeDomain); @@ -108,54 +109,46 @@ oslSecurityError SAL_CALL osl_loginUser( rtl_uString *strUserName, rtl_uString * { oslSecurityError ret; - if (!isWNT()) - { - *pSecurity = osl_getCurrentSecurity(); - ret = osl_Security_E_None; - } + sal_Unicode* strUser; + sal_Unicode* strDomain = _wcsdup(rtl_uString_getStr(strUserName)); + HANDLE hUserToken; + + #if OSL_DEBUG_LEVEL > 0 + LUID luid; + #endif + + if (NULL != (strUser = wcschr(strDomain, L'/'))) + *strUser++ = L'\0'; else { - sal_Unicode* strUser; - sal_Unicode* strDomain = _wcsdup(rtl_uString_getStr(strUserName)); - HANDLE hUserToken; - - #if OSL_DEBUG_LEVEL > 0 - LUID luid; - #endif - - if (NULL != (strUser = wcschr(strDomain, L'/'))) - *strUser++ = L'\0'; - else - { - strUser = strDomain; - strDomain = NULL; - } - - // this process must have the right: 'act as a part of operatingsystem' - OSL_ASSERT(LookupPrivilegeValue(NULL, SE_TCB_NAME, &luid)); + strUser = strDomain; + strDomain = NULL; + } - if (LogonUserW(strUser, strDomain ? strDomain : L"", rtl_uString_getStr(strPasswd), - LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, - &hUserToken)) - { - oslSecurityImpl* pSecImpl = malloc(sizeof(oslSecurityImpl)); + // this process must have the right: 'act as a part of operatingsystem' + OSL_ASSERT(LookupPrivilegeValue(NULL, SE_TCB_NAME, &luid)); - pSecImpl->m_pNetResource = NULL; - pSecImpl->m_hToken = hUserToken; - pSecImpl->m_hProfile = NULL; - wcscpy(pSecImpl->m_User, strUser); + if (LogonUserW(strUser, strDomain ? strDomain : L"", rtl_uString_getStr(strPasswd), + LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, + &hUserToken)) + { + oslSecurityImpl* pSecImpl = malloc(sizeof(oslSecurityImpl)); - *pSecurity = (oslSecurity)pSecImpl; - ret = osl_Security_E_None; - } - else - ret = osl_Security_E_UserUnknown; + pSecImpl->m_pNetResource = NULL; + pSecImpl->m_hToken = hUserToken; + pSecImpl->m_hProfile = NULL; + wcscpy(pSecImpl->m_User, strUser); - if (strDomain) - free(strDomain); - else - free(strUser); + *pSecurity = (oslSecurity)pSecImpl; + ret = osl_Security_E_None; } + else + ret = osl_Security_E_UserUnknown; + + if (strDomain) + free(strDomain); + else + free(strUser); return ret; } @@ -250,56 +243,48 @@ sal_Bool SAL_CALL osl_isAdministrator(oslSecurity Security) { if (Security != NULL) { - /* ts: on Window 95 systems any user seems to be an adminstrator */ - if (!isWNT()) - { - return(sal_True); - } - else - { - HANDLE hImpersonationToken = NULL; - PSID psidAdministrators; - SID_IDENTIFIER_AUTHORITY siaNtAuthority = SECURITY_NT_AUTHORITY; - sal_Bool bSuccess = sal_False; - + HANDLE hImpersonationToken = NULL; + PSID psidAdministrators; + SID_IDENTIFIER_AUTHORITY siaNtAuthority = SECURITY_NT_AUTHORITY; + sal_Bool bSuccess = sal_False; - /* If Security contains an access token we need to duplicate it to an impersonation - access token. NULL works with CheckTokenMembership() as the current effective - impersonation token - */ - if ( ((oslSecurityImpl*)Security)->m_hToken ) - { - if ( !DuplicateToken (((oslSecurityImpl*)Security)->m_hToken, SecurityImpersonation, &hImpersonationToken) ) - return sal_False; - } + /* If Security contains an access token we need to duplicate it to an impersonation + access token. NULL works with CheckTokenMembership() as the current effective + impersonation token + */ - /* CheckTokenMembership() can be used on W2K and higher (NT4 no longer supported by OOo) - and also works on Vista to retrieve the effective user rights. Just checking for - membership of Administrators group is not enough on Vista this would require additional - complicated checks as described in KB arcticle Q118626: http://support.microsoft.com/kb/118626/en-us - */ + if ( ((oslSecurityImpl*)Security)->m_hToken ) + { + if ( !DuplicateToken (((oslSecurityImpl*)Security)->m_hToken, SecurityImpersonation, &hImpersonationToken) ) + return sal_False; + } - if (AllocateAndInitializeSid(&siaNtAuthority, - 2, - SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, - &psidAdministrators)) - { - BOOL fSuccess = FALSE; + /* CheckTokenMembership() can be used on W2K and higher (NT4 no longer supported by OOo) + and also works on Vista to retrieve the effective user rights. Just checking for + membership of Administrators group is not enough on Vista this would require additional + complicated checks as described in KB arcticle Q118626: http://support.microsoft.com/kb/118626/en-us + */ + + if (AllocateAndInitializeSid(&siaNtAuthority, + 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, 0, 0, 0, 0, 0, + &psidAdministrators)) + { + BOOL fSuccess = FALSE; - if ( CheckTokenMembership_Stub( hImpersonationToken, psidAdministrators, &fSuccess ) && fSuccess ) - bSuccess = sal_True; + if ( CheckTokenMembership_Stub( hImpersonationToken, psidAdministrators, &fSuccess ) && fSuccess ) + bSuccess = sal_True; - FreeSid(psidAdministrators); - } + FreeSid(psidAdministrators); + } - if ( hImpersonationToken ) - CloseHandle( hImpersonationToken ); + if ( hImpersonationToken ) + CloseHandle( hImpersonationToken ); - return (bSuccess); - } + return (bSuccess); } else return (sal_False); @@ -353,7 +338,17 @@ sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent) pInfoBuffer, nInfoBuffer, &nInfoBuffer)) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - pInfoBuffer = realloc(pInfoBuffer, nInfoBuffer); + { + UCHAR* pTmp = realloc(pInfoBuffer, nInfoBuffer); + if (pTmp) + pInfoBuffer = pTmp; + else + { + free(pInfoBuffer); + pInfoBuffer = NULL; + break; + } + } else { free(pInfoBuffer); @@ -756,7 +751,7 @@ static sal_Bool GetSpecialFolder(rtl_uString **strPath, int nFolder) &hRegKey) == ERROR_SUCCESS) { LONG lRet; - DWORD lSize = elementsof(PathA); + DWORD lSize = SAL_N_ELEMENTS(PathA); DWORD Type = REG_SZ; switch (nFolder) @@ -823,38 +818,6 @@ static sal_Bool GetSpecialFolder(rtl_uString **strPath, int nFolder) } -static sal_Bool isWNT(void) -{ - static sal_Bool isInit = sal_False; - static sal_Bool isWNT = sal_False; - - if (!isInit) - { - OSVERSIONINFO VersionInformation = - - { - sizeof(OSVERSIONINFO), - 0, - 0, - 0, - 0, - "", - }; - - if ( - GetVersionEx(&VersionInformation) && - (VersionInformation.dwPlatformId == VER_PLATFORM_WIN32_NT) - ) - { - isWNT = sal_True; - } - - isInit = sal_True; - } - - return(isWNT); -} - static BOOL Privilege(LPTSTR strPrivilege, BOOL bEnable) { HANDLE hToken; @@ -911,7 +874,17 @@ static sal_Bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **str pInfoBuffer, nInfoBuffer, &nInfoBuffer)) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - pInfoBuffer = realloc(pInfoBuffer, nInfoBuffer); + { + UCHAR* pTmp = realloc(pInfoBuffer, nInfoBuffer); + if (pTmp) + pInfoBuffer = pTmp; + else + { + free(pInfoBuffer); + pInfoBuffer = NULL; + break; + } + } else { free(pInfoBuffer); @@ -989,3 +962,4 @@ static sal_Bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **str return sal_False; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/semaphor.c b/sal/osl/w32/semaphor.c index 44bcac70a..e4a72268a 100644 --- a/sal/osl/w32/semaphor.c +++ b/sal/osl/w32/semaphor.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -109,3 +110,4 @@ sal_Bool SAL_CALL osl_releaseSemaphore(oslSemaphore Semaphore) +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/signal.cxx b/sal/osl/w32/signal.cxx index f42edcd89..4520cbe21 100644 --- a/sal/osl/w32/signal.cxx +++ b/sal/osl/w32/signal.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -38,8 +39,9 @@ #ifndef __MINGW32__ #include <DbgHelp.h> #endif -#include <ErrorRep.h> +#include <errorrep.h> #include <systools/win32/uwinapi.h> +#include <sal/macros.h> typedef struct _oslSignalHandlerImpl { @@ -186,7 +188,7 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP ) StartupInfo.cb = sizeof(StartupInfo.cb); - sntprintf( szBuffer, elementsof(szBuffer), + sntprintf( szBuffer, SAL_N_ELEMENTS(szBuffer), _T("%s -p %u -excp 0x%p -t %u%s"), static_cast<sal_Char*>( aPath ), GetCurrentProcessId(), @@ -434,3 +436,5 @@ sal_Bool SAL_CALL osl_setErrorReporting( sal_Bool bEnable ) return bOld; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx index c71da4e40..fe26f5e35 100644 --- a/sal/osl/w32/socket.cxx +++ b/sal/osl/w32/socket.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -289,25 +290,6 @@ static oslSocketError osl_SocketErrorFromNative(int nativeType) /*****************************************************************************/ static oslSocketDialupImpl *pDialupImpl = NULL; -#if 0 /* INTERNAL DEBUG ONLY */ -BOOL WINAPI __osl_autodial_Impl (DWORD dwFlags, DWORD dwReserved) -{ - return 0; -} - -BOOL WINAPI __osl_autodialHangup_Impl (DWORD dwReserved) -{ - return 1; -} - -BOOL WINAPI __osl_getConnectedState_Impl (LPDWORD lpdwFlags, DWORD dwReserved) -{ - if (lpdwFlags) - *lpdwFlags = 0; - return 0; -} -#endif /* INTERNAL DEBUG ONLY */ - /* * __osl_createSocketDialupImpl. */ @@ -350,7 +332,7 @@ static void __osl_initSocketDialupImpl (oslSocketDialupImpl *pImpl) LeaveCriticalSection (&pImpl->m_hMutex); } #else - pImpl = pImpl; /* avoid warnings */ + (void)pImpl; #endif } @@ -582,6 +564,8 @@ oslSocketAddr SAL_CALL osl_copySocketAddr(oslSocketAddr Addr) /*****************************************************************************/ sal_Bool SAL_CALL osl_isEqualSocketAddr(oslSocketAddr Addr1, oslSocketAddr Addr2) { + OSL_ASSERT(Addr1); + OSL_ASSERT(Addr2); struct sockaddr* pAddr1= &(Addr1->m_sockaddr); struct sockaddr* pAddr2= &(Addr2->m_sockaddr); @@ -605,7 +589,7 @@ sal_Bool SAL_CALL osl_isEqualSocketAddr(oslSocketAddr Addr1, oslSocketAddr Addr2 default: { - return (memcmp(pAddr1, Addr2, sizeof(struct sockaddr)) == 0); + return (memcmp(pAddr1, pAddr2, sizeof(struct sockaddr)) == 0); } } } @@ -1565,7 +1549,7 @@ sal_Int32 SAL_CALL osl_readSocket( oslSocket pSocket, void *pBuffer, sal_Int32 n OSL_ASSERT( pSocket); - /* loop until all desired bytes were read or an error occured */ + /* loop until all desired bytes were read or an error occurred */ sal_uInt32 BytesRead= 0; sal_uInt32 BytesToRead= n; while (BytesToRead > 0) @@ -1576,7 +1560,7 @@ sal_Int32 SAL_CALL osl_readSocket( oslSocket pSocket, void *pBuffer, sal_Int32 n BytesToRead, osl_Socket_MsgNormal); - /* error occured? */ + /* error occurred? */ if(RetVal <= 0) { break; @@ -1597,7 +1581,7 @@ sal_Int32 SAL_CALL osl_writeSocket( oslSocket pSocket, const void *pBuffer, sal_ { OSL_ASSERT( pSocket ); - /* loop until all desired bytes were send or an error occured */ + /* 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; @@ -1607,7 +1591,7 @@ sal_Int32 SAL_CALL osl_writeSocket( oslSocket pSocket, const void *pBuffer, sal_ RetVal= osl_sendSocket( pSocket,Ptr,BytesToSend,osl_Socket_MsgNormal); - /* error occured? */ + /* error occurred? */ if(RetVal <= 0) { break; @@ -2188,3 +2172,5 @@ sal_Int32 SAL_CALL osl_demultiplexSocketEvents ( } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/sockimpl.h b/sal/osl/w32/sockimpl.h index d2e68da75..6bffb9f4a 100644 --- a/sal/osl/w32/sockimpl.h +++ b/sal/osl/w32/sockimpl.h @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -106,3 +107,4 @@ static sal_Bool __osl_attemptSocketDialupImpl (void); #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/system.h b/sal/osl/w32/system.h index 2bb432394..d778828a1 100644 --- a/sal/osl/w32/system.h +++ b/sal/osl/w32/system.h @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -104,23 +105,4 @@ # define NSPROTO_SPXII 1257 #endif // #ifdef GCC -#ifdef _DLL_ - -#ifdef __cplusplus - extern "C" DWORD g_dwPlatformId; -#else - extern DWORD g_dwPlatformId; -#endif // #ifdef __cplusplus - - #define IS_NT (g_dwPlatformId == VER_PLATFORM_WIN32_NT) -#else - -#ifdef __cplusplus - extern "C" DWORD GetPlatformId(void); -#else - extern DWORD GetPlatformId(void); -#endif // #ifdef __cplusplus - - #define IS_NT (GetPlatformId() == VER_PLATFORM_WIN32_NT) -#endif // #ifdef _DLL_ - +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx index 63a5d9a61..2b43af005 100644 --- a/sal/osl/w32/tempfile.cxx +++ b/sal/osl/w32/tempfile.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,7 +28,7 @@ #define UNICODE #define _UNICODE -#define _WIN32_WINNT_0x0500 +#define _WIN32_WINNT 0x0500 #include "systools/win32/uwinapi.h" #include "osl/file.h" @@ -42,8 +43,6 @@ #include <tchar.h> //##################################################### -#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0]))) - // Allocate n number of t's on the stack return a pointer to it in p #ifdef __MINGW32__ #define STACK_ALLOC(p, t, n) (p) = reinterpret_cast<t*>(_alloca((n)*sizeof(t))); @@ -272,3 +271,4 @@ oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir) return error; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/thread.c b/sal/osl/w32/thread.c index 64297864f..fc0c5ab37 100755 --- a/sal/osl/w32/thread.c +++ b/sal/osl/w32/thread.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -616,3 +617,4 @@ rtl_TextEncoding SAL_CALL osl_setThreadTextEncoding( rtl_TextEncoding Encoding ) +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/time.c b/sal/osl/w32/time.c index 273d785bf..6ce388d32 100644 --- a/sal/osl/w32/time.c +++ b/sal/osl/w32/time.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -214,3 +215,4 @@ sal_uInt32 SAL_CALL osl_getGlobalTimer(void) return ( nSeconds * 1000 ) + (long)( currentTime.millitm - startTime.millitm ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/util.c b/sal/osl/w32/util.c index b72572fff..ebf5a43eb 100644 --- a/sal/osl/w32/util.c +++ b/sal/osl/w32/util.c @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,10 @@ -extern sal_Bool SAL_CALL osl_getEthernetAddress( sal_uInt8 *pAddr ) +extern sal_Bool SAL_CALL osl_getEthernetAddress( sal_uInt8* pAddr ) { - pAddr = pAddr; /* avoid warnings */ + (void)pAddr; //unused, but part of the API/ABI return sal_False; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |