diff options
author | Tor Lillqvist <tlillqvist@novell.com> | 2011-01-24 01:57:17 +0200 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@novell.com> | 2011-01-24 01:57:17 +0200 |
commit | 1e04593caf52dbcbc4cf6eecfb46634a9454faa2 (patch) | |
tree | 6e32029bf45c37e34766f6869718d05b393f4d2a /sal/osl | |
parent | 0ec0d899bf81a957347f0e3e257928a2e5945e30 (diff) |
Kill Win9x code
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/w32/MAKEFILE.MK | 4 | ||||
-rw-r--r-- | sal/osl/w32/dllentry.c | 19 | ||||
-rw-r--r-- | sal/osl/w32/libutil.c | 57 | ||||
-rw-r--r-- | sal/osl/w32/module.cxx | 72 | ||||
-rw-r--r-- | sal/osl/w32/pipe.c | 328 | ||||
-rw-r--r-- | sal/osl/w32/pipeimpl.cxx | 772 | ||||
-rw-r--r-- | sal/osl/w32/pipeimpl.h | 91 | ||||
-rw-r--r-- | sal/osl/w32/system.h | 20 |
8 files changed, 110 insertions, 1253 deletions
diff --git a/sal/osl/w32/MAKEFILE.MK b/sal/osl/w32/MAKEFILE.MK index 4749048847b5..a76017199c3f 100644 --- a/sal/osl/w32/MAKEFILE.MK +++ b/sal/osl/w32/MAKEFILE.MK @@ -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/dllentry.c b/sal/osl/w32/dllentry.c index 2004d30669ca..4d894260446a 100644 --- a/sal/osl/w32/dllentry.c +++ b/sal/osl/w32/dllentry.c @@ -90,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__ @@ -177,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); @@ -193,7 +183,7 @@ 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 ); @@ -205,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 ); diff --git a/sal/osl/w32/libutil.c b/sal/osl/w32/libutil.c deleted file mode 100644 index c7f4501b156d..000000000000 --- a/sal/osl/w32/libutil.c +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx index 1171401fe0c1..870eb7533b72 100644 --- a/sal/osl/w32/module.cxx +++ b/sal/osl/w32/module.cxx @@ -189,73 +189,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) */ /***************************************************************************************/ @@ -455,10 +388,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 ); } /*****************************************************************************/ diff --git a/sal/osl/w32/pipe.c b/sal/osl/w32/pipe.c index 31e3c8ec17ad..9efe5e91e8b2 100644 --- a/sal/osl/w32/pipe.c +++ b/sal/osl/w32/pipe.c @@ -28,8 +28,6 @@ #include "system.h" -#include "pipeimpl.h" - #include <osl/pipe.h> #include <osl/diagnose.h> #include <osl/thread.h> @@ -139,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; @@ -189,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 ) { @@ -211,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) - { - rtl_uString_release( name ); - rtl_uString_release( path ); - - return pPipe; - } - } - else /* Win 9x */ + /* 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) { - LPSTR pszTempBuffer = NULL; - int nCharsNeeded; + rtl_uString_release( name ); + rtl_uString_release( path ); - 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 @@ -261,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 */ @@ -352,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); } - } } @@ -380,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 @@ -426,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); - 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; - 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); - pAcceptedPipe->m_File = AcceptSimplePipeConnection( pPipe->m_File ); - } + // 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; } @@ -475,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; - - ResetEvent(pPipe->m_ReadEvent); + rtl_zeroMemory(&os,sizeof(OVERLAPPED)); + os.hEvent = 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; + ResetEvent(pPipe->m_ReadEvent); - pPipe->m_Error = osl_Pipe_E_ConnectionAbort; - } - } - } - else + 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); @@ -529,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); diff --git a/sal/osl/w32/pipeimpl.cxx b/sal/osl/w32/pipeimpl.cxx deleted file mode 100644 index 9fa2bc85e5fb..000000000000 --- a/sal/osl/w32/pipeimpl.cxx +++ /dev/null @@ -1,772 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/pipeimpl.h b/sal/osl/w32/pipeimpl.h deleted file mode 100644 index be6665bd4b5a..000000000000 --- a/sal/osl/w32/pipeimpl.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#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_ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/system.h b/sal/osl/w32/system.h index 491c2daa7bbe..163d8232a35a 100644 --- a/sal/osl/w32/system.h +++ b/sal/osl/w32/system.h @@ -105,24 +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: */ |