This is an automated email from the ASF dual-hosted git repository.
mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push:
new d890342d80 Cleanup
d890342d80 is described below
commit d890342d807e0a01fcf6b9d8dcbfdc4ab10f0e60
Author: mseidel <[email protected]>
AuthorDate: Thu Apr 3 10:38:38 2025 +0200
Cleanup
(cherry picked from commit d28058dba277e5685bb46851ba480f136eb162bc)
---
main/sal/osl/w32/module.cxx | 81 ++++++++-------
main/sal/osl/w32/path_helper.cxx | 82 +++++++--------
main/sal/osl/w32/salinit.cxx | 90 ++++++++---------
main/sal/osl/w32/signal.cxx | 108 ++++++++++----------
main/sal/osl/w32/tempfile.cxx | 208 +++++++++++++++++++--------------------
5 files changed, 284 insertions(+), 285 deletions(-)
diff --git a/main/sal/osl/w32/module.cxx b/main/sal/osl/w32/module.cxx
index e593b0bf45..951e9f80c2 100644
--- a/main/sal/osl/w32/module.cxx
+++ b/main/sal/osl/w32/module.cxx
@@ -19,8 +19,6 @@
*
*************************************************************/
-
-
#include "system.h"
#include <tlhelp32.h>
@@ -65,25 +63,25 @@ oslModule SAL_CALL osl_loadModule(rtl_uString
*strModuleName, sal_Int32 nRtldMod
if (hInstance == NULL)
hInstance =
LoadLibraryExW(reinterpret_cast<LPCWSTR>(Module->buffer), NULL,
- LOAD_WITH_ALTERED_SEARCH_PATH);
+
LOAD_WITH_ALTERED_SEARCH_PATH);
- //In case of long path names (\\?\c:\...) try to shorten the filename.
- //LoadLibrary cannot handle file names which exceed 260 letters.
- //In case the path is to long, the function will fail. However, the
error
- //code can be different. For example, it returned
ERROR_FILENAME_EXCED_RANGE
- //on Windows XP and ERROR_INSUFFICIENT_BUFFER on Windows 7 (64bit)
+ // In case of long path names (\\?\c:\...) try to shorten the filename.
+ // LoadLibrary cannot handle file names which exceed 260 letters.
+ // In case the path is too long, the function will fail. However, the
error
+ // code can be different. For example, it returned
ERROR_FILENAME_EXCEED_RANGE
+ // on Windows XP and ERROR_INSUFFICIENT_BUFFER on Windows 7 (64bit)
if (hInstance == NULL && Module->length > 260)
{
std::vector<WCHAR> vec(Module->length + 1);
DWORD len =
GetShortPathNameW(reinterpret_cast<LPCWSTR>(Module->buffer),
- &vec[0], Module->length + 1);
+
&vec[0], Module->length + 1);
if (len )
{
hInstance = LoadLibraryW(&vec[0]);
if (hInstance == NULL)
hInstance = LoadLibraryExW(&vec[0], NULL,
- LOAD_WITH_ALTERED_SEARCH_PATH);
+
LOAD_WITH_ALTERED_SEARCH_PATH);
}
}
@@ -142,15 +140,15 @@ void SAL_CALL osl_unloadModule(oslModule Module)
/*****************************************************************************/
void* SAL_CALL osl_getSymbol(oslModule Module, rtl_uString *strSymbolName)
{
- /* casting from a function pointer to a data pointer is invalid
- be in this case unavoidable because the API has to stay
- compatible we need to keep this function which returns a
- void* by definition */
+ /* casting from a function pointer to a data pointer is invalid
+ be in this case unavoidable because the API has to stay
+ compatible we need to keep this function which returns a
+ void* by definition */
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4054)
#endif
- return (void*)(osl_getFunctionSymbol(Module, strSymbolName));
+ return (void*)(osl_getFunctionSymbol(Module, strSymbolName));
#ifdef _MSC_VER
#pragma warning(pop)
#endif
@@ -196,7 +194,6 @@ osl_getAsciiFunctionSymbol( oslModule Module, const
sal_Char *pSymbol )
}
-
/*****************************************************************************/
/* osl_addressGetModuleURL */
/*****************************************************************************/
@@ -295,20 +292,20 @@ static sal_Bool SAL_CALL
_osl_addressGetModuleURL_Windows( void *pv, rtl_uString
#endif
typedef BOOL (WINAPI *SymInitialize_PROC)(
- HANDLE hProcess,
- LPSTR UserSearchPath,
- BOOL fInvadeProcess
- );
+ HANDLE hProcess,
+ LPSTR UserSearchPath,
+ BOOL fInvadeProcess
+ );
typedef BOOL (WINAPI *SymCleanup_PROC)(
- HANDLE hProcess
+ HANDLE hProcess
);
typedef BOOL (WINAPI *SymGetModuleInfo_PROC)(
- HANDLE hProcess,
- DWORD dwAddr,
- PIMAGEHLP_MODULE ModuleInfo
- );
+ HANDLE hProcess,
+ DWORD dwAddr,
+ PIMAGEHLP_MODULE ModuleInfo
+ );
/* Seems that IMAGEHLP.DLL is always available on NT 4. But MSDN from Platform
SDK says Win 2K is required. MSDN from VS 6.0a says
it's OK on NT 4 ???!!!
@@ -400,23 +397,23 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4(
void *pv, rtl_uString **p
typedef struct _MODULEINFO {
- LPVOID lpBaseOfDll;
- DWORD SizeOfImage;
- LPVOID EntryPoint;
+ LPVOID lpBaseOfDll;
+ DWORD SizeOfImage;
+ LPVOID EntryPoint;
} MODULEINFO, *LPMODULEINFO;
typedef BOOL (WINAPI *EnumProcessModules_PROC)(
- HANDLE hProcess, // handle to the process
- HMODULE * lphModule, // array to receive the module handles
- DWORD cb, // size of the array
- LPDWORD lpcbNeeded // receives the number of bytes returned
+ HANDLE hProcess, // handle to the process
+ HMODULE * lphModule, // array to receive the module handles
+ DWORD cb, // size of the array
+ LPDWORD lpcbNeeded // receives the number of bytes returned
);
typedef BOOL (WINAPI *GetModuleInformation_PROC)(
- HANDLE hProcess, // handle to the process
- HMODULE hModule, // handle to the module
- LPMODULEINFO lpmodinfo, // structure that receives information
- DWORD cb // size of the structure
+ HANDLE hProcess, // handle to the process
+ HMODULE hModule, // handle to the module
+ LPMODULEINFO lpmodinfo, // structure that receives information
+ DWORD cb // size of the structure
);
#define bufsizeof(buffer) (sizeof(buffer) / sizeof((buffer)[0]))
@@ -494,16 +491,18 @@ sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv,
rtl_uString **pustrURL
/*****************************************************************************/
sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress( oslGenericFunction
addr, rtl_uString ** ppLibraryUrl )
{
- /* casting a function pointer to a data pointer (void*) is
- not allowed according to the C/C++ standards. In this case
- it is unavoidable because we have to stay compatible we
- cannot remove any function. */
+ /* casting a function pointer to a data pointer (void*) is
+ not allowed according to the C/C++ standards. In this case
+ it is unavoidable because we have to stay compatible we
+ cannot remove any function. */
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4054)
#endif
- return osl_getModuleURLFromAddress((void*)addr, ppLibraryUrl);
+ return osl_getModuleURLFromAddress((void*)addr, ppLibraryUrl);
#ifdef _MSC_VER
#pragma warning(pop)
#endif
}
+
+/* vim: set noet sw=4 ts=4: */
diff --git a/main/sal/osl/w32/path_helper.cxx b/main/sal/osl/w32/path_helper.cxx
index 0e2d89ca31..3277cc3aff 100644
--- a/main/sal/osl/w32/path_helper.cxx
+++ b/main/sal/osl/w32/path_helper.cxx
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,27 +7,25 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
-
-
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sal.hxx"
/*******************************************************************
Includes
******************************************************************/
-
+
#include "path_helper.hxx"
#include <osl/diagnose.h>
#include <rtl/ustring.hxx>
@@ -38,28 +36,28 @@
/*******************************************************************
Constants
******************************************************************/
-
+
const rtl::OUString BACKSLASH = rtl::OUString::createFromAscii("\\");
const rtl::OUString SLASH = rtl::OUString::createFromAscii("/");
/*******************************************************************
osl_systemPathEnsureSeparator
******************************************************************/
-
+
void osl_systemPathEnsureSeparator(/*inout*/ rtl_uString** ppustrPath)
{
- OSL_PRECOND(ppustrPath && (NULL != *ppustrPath), \
+ OSL_PRECOND(ppustrPath && (NULL != *ppustrPath), \
"osl_systemPathEnsureSeparator: Invalid
parameter");
-
- rtl::OUString path(*ppustrPath);
+
+ rtl::OUString path(*ppustrPath);
sal_Int32 i = std::max<sal_Int32>(path.lastIndexOf(BACKSLASH),
path.lastIndexOf(SLASH));
-
+
if (i < (path.getLength()-1))
{
- path += BACKSLASH;
- rtl_uString_assign(ppustrPath, path.pData);
+ path += BACKSLASH;
+ rtl_uString_assign(ppustrPath, path.pData);
}
-
+
OSL_POSTCOND(path.lastIndexOf(BACKSLASH) == (path.getLength() - 1), \
"osl_systemPathEnsureSeparator: Post condition
failed");
}
@@ -67,21 +65,21 @@ void osl_systemPathEnsureSeparator(/*inout*/ rtl_uString**
ppustrPath)
/*******************************************************************
osl_systemPathRemoveSeparator
******************************************************************/
-
+
void SAL_CALL osl_systemPathRemoveSeparator(/*inout*/ rtl_uString** ppustrPath)
{
- rtl::OUString path(*ppustrPath);
-
- if (!osl::systemPathIsLogicalDrivePattern(path))
- {
- sal_Int32 i = std::max<sal_Int32>(path.lastIndexOf(BACKSLASH),
path.lastIndexOf(SLASH));
-
- if (i > -1 && (i == (path.getLength() - 1)))
- {
- path = rtl::OUString(path.getStr(), path.getLength() - 1);
- rtl_uString_assign(ppustrPath, path.pData);
- }
- }
+ rtl::OUString path(*ppustrPath);
+
+ if (!osl::systemPathIsLogicalDrivePattern(path))
+ {
+ sal_Int32 i = std::max<sal_Int32>(path.lastIndexOf(BACKSLASH),
path.lastIndexOf(SLASH));
+
+ if (i > -1 && (i == (path.getLength() - 1)))
+ {
+ path = rtl::OUString(path.getStr(), path.getLength() -
1);
+ rtl_uString_assign(ppustrPath, path.pData);
+ }
+ }
}
/*******************************************************************
@@ -92,21 +90,23 @@ void SAL_CALL osl_systemPathRemoveSeparator(/*inout*/
rtl_uString** ppustrPath)
const sal_Char* LDP = ":";
const sal_Char* LDP_WITH_BACKSLASH = ":\\";
const sal_Char* LDP_WITH_SLASH = ":/";
-
-// degenerated case returned by the Windows FileOpen dialog
+
+// degenerated case returned by the Windows FileOpen dialog
// when someone enters for instance "x:filename", the Win32
// API accepts this case
const sal_Char* LDP_WITH_DOT_BACKSLASH = ":.\\";
-
+
sal_Int32 osl_systemPathIsLogicalDrivePattern(/*in*/ const rtl_uString*
pustrPath)
{
- const sal_Unicode* p =
rtl_uString_getStr(const_cast<rtl_uString*>(pustrPath));
- if (iswalpha(*p++))
- {
- return ((0 == rtl_ustr_ascii_compare(p, LDP)) ||
- (0 == rtl_ustr_ascii_compare(p, LDP_WITH_BACKSLASH)) ||
- (0 == rtl_ustr_ascii_compare(p, LDP_WITH_SLASH)) ||
- (0 == rtl_ustr_ascii_compare(p, LDP_WITH_DOT_BACKSLASH)));
- }
- return 0;
+ const sal_Unicode* p =
rtl_uString_getStr(const_cast<rtl_uString*>(pustrPath));
+ if (iswalpha(*p++))
+ {
+ return ((0 == rtl_ustr_ascii_compare(p, LDP)) ||
+ (0 == rtl_ustr_ascii_compare(p,
LDP_WITH_BACKSLASH)) ||
+ (0 == rtl_ustr_ascii_compare(p,
LDP_WITH_SLASH)) ||
+ (0 == rtl_ustr_ascii_compare(p,
LDP_WITH_DOT_BACKSLASH)));
+ }
+ return 0;
}
+
+/* vim: set noet sw=4 ts=4: */
diff --git a/main/sal/osl/w32/salinit.cxx b/main/sal/osl/w32/salinit.cxx
index d32c372952..fcaa2f6d54 100644
--- a/main/sal/osl/w32/salinit.cxx
+++ b/main/sal/osl/w32/salinit.cxx
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,20 +7,18 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
-
-
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sal.hxx"
@@ -36,51 +34,51 @@ extern "C" {
void SAL_CALL sal_detail_initialize(int argc, char ** argv)
{
- // SetProcessDEPPolicy(PROCESS_DEP_ENABLE);
- // SetDllDirectoryW(L"");
- // SetSearchPathMode(
- // BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT);
- HMODULE h = GetModuleHandleW(L"kernel32.dll");
- if (h != 0) {
- FARPROC p = GetProcAddress(h, "SetProcessDEPPolicy");
- if (p != 0) {
- reinterpret_cast< BOOL (WINAPI *)(DWORD) >(p)(0x00000001);
+ // SetProcessDEPPolicy(PROCESS_DEP_ENABLE);
+ // SetDllDirectoryW(L"");
+ // SetSearchPathMode(
+ // BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE |
BASE_SEARCH_PATH_PERMANENT);
+ HMODULE h = GetModuleHandleW(L"kernel32.dll");
+ if (h != 0) {
+ FARPROC p = GetProcAddress(h, "SetProcessDEPPolicy");
+ if (p != 0) {
+ reinterpret_cast< BOOL (WINAPI *)(DWORD)
>(p)(0x00000001);
}
p = GetProcAddress(h, "SetDllDirectoryW");
- if (p != 0) {
- reinterpret_cast< BOOL (WINAPI *)(LPCWSTR) >(p)(L"");
- }
- p = GetProcAddress(h, "SetSearchPathMode");
- if (p != 0) {
- reinterpret_cast< BOOL (WINAPI *)(DWORD) >(p)(0x8001);
- }
- }
-
- WSADATA wsaData;
- int error;
- WORD wVersionRequested;
+ if (p != 0) {
+ reinterpret_cast< BOOL (WINAPI *)(LPCWSTR) >(p)(L"");
+ }
+ p = GetProcAddress(h, "SetSearchPathMode");
+ if (p != 0) {
+ reinterpret_cast< BOOL (WINAPI *)(DWORD) >(p)(0x8001);
+ }
+ }
- wVersionRequested = MAKEWORD(1, 1);
+ WSADATA wsaData;
+ int error;
+ WORD wVersionRequested;
- error = WSAStartup(wVersionRequested, &wsaData);
- if ( 0 == error )
- {
- WORD wMajorVersionRequired = 1;
- WORD wMinorVersionRequired = 1;
+ wVersionRequested = MAKEWORD(1, 1);
- if ((LOBYTE(wsaData.wVersion) < wMajorVersionRequired) ||
- (LOBYTE(wsaData.wVersion) == wMajorVersionRequired) &&
- ((HIBYTE(wsaData.wVersion) < wMinorVersionRequired)))
- {
- // How to handle a very unlikely error ???
- }
- }
- else
- {
- // How to handle a very unlikely error ???
- }
+ error = WSAStartup(wVersionRequested, &wsaData);
+ if ( 0 == error )
+ {
+ WORD wMajorVersionRequired = 1;
+ WORD wMinorVersionRequired = 1;
+
+ if ((LOBYTE(wsaData.wVersion) < wMajorVersionRequired) ||
+ (LOBYTE(wsaData.wVersion) == wMajorVersionRequired) &&
+ ((HIBYTE(wsaData.wVersion) < wMinorVersionRequired)))
+ {
+ // How to handle a very unlikely error ???
+ }
+ }
+ else
+ {
+ // How to handle a very unlikely error ???
+ }
- osl_setCommandArgs(argc, argv);
+ osl_setCommandArgs(argc, argv);
}
void SAL_CALL sal_detail_deinitialize()
@@ -96,3 +94,5 @@ void SAL_CALL sal_detail_deinitialize()
#ifdef __cplusplus
} // extern "C"
#endif
+
+/* vim: set noet sw=4 ts=4: */
diff --git a/main/sal/osl/w32/signal.cxx b/main/sal/osl/w32/signal.cxx
index 8b3af0970c..698d3612a1 100644
--- a/main/sal/osl/w32/signal.cxx
+++ b/main/sal/osl/w32/signal.cxx
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,20 +7,18 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
-
-
/* system headers */
#include "system.h"
#include <tchar.h>
@@ -41,13 +39,13 @@
typedef struct _oslSignalHandlerImpl
{
- oslSignalHandlerFunction Handler;
- void* pData;
- struct _oslSignalHandlerImpl* pNext;
+ oslSignalHandlerFunction Handler;
+ void* pData;
+ struct _oslSignalHandlerImpl* pNext;
} oslSignalHandlerImpl;
static sal_Bool bErrorReportingEnabled =
sal_True;
-static sal_Bool bInitSignal = sal_False;
+static sal_Bool bInitSignal = sal_False;
static oslMutex SignalListMutex;
static oslSignalHandlerImpl* SignalList;
@@ -113,7 +111,7 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
BOOL fSuccess = FALSE;
BOOL fAutoReport = FALSE;
TCHAR szBuffer[1024];
- ::osl::LongPathBuffer< sal_Char > aPath( MAX_LONG_PATH );
+ ::osl::LongPathBuffer< sal_Char > aPath( MAX_LONG_PATH );
LPTSTR lpFilePart;
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo;
@@ -126,18 +124,18 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
for ( argi = 1; argi < __argc; argi++ )
{
- if (
- 0 == stricmp( __argv[argi], "-nocrashreport" ) ||
+ if (
+ 0 == stricmp( __argv[argi], "-nocrashreport" ) ||
0 == stricmp( __argv[argi], "/nocrashreport" )
)
return FALSE;
else if (
- 0 == stricmp( __argv[argi], "-autocrashreport" ) ||
+ 0 == stricmp( __argv[argi], "-autocrashreport" ) ||
0 == stricmp( __argv[argi], "/autocrashreport" )
)
fAutoReport = TRUE;
else if (
- 0 == strnicmp( __argv[argi], REPORTENV_PARAM,
strlen(REPORTENV_PARAM) ) ||
+ 0 == strnicmp( __argv[argi], REPORTENV_PARAM,
strlen(REPORTENV_PARAM) ) ||
0 == strnicmp( __argv[argi], REPORTENV_PARAM2,
strlen(REPORTENV_PARAM2) )
)
{
@@ -152,7 +150,7 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
size_t variable_len = delim - envparam;
const char *value = delim + 1;
size_t value_len = strlen(envparam) -
variable_len - 1;
-
+
if ( '\"' == *value )
{
const char *quote;
@@ -173,7 +171,7 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
memcpy( lpValue, value, value_len );
lpValue[value_len] = 0;
- SetEnvironmentVariable( lpVariable, lpValue );
+ SetEnvironmentVariable( lpVariable, lpValue );
}
}
}
@@ -184,34 +182,34 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
StartupInfo.cb = sizeof(StartupInfo.cb);
- sntprintf( szBuffer, elementsof(szBuffer),
- _T("%s -p %u -excp 0x%p -t %u%s"),
- static_cast<sal_Char*>( aPath ),
- GetCurrentProcessId(),
- lpEP,
+ sntprintf( szBuffer, elementsof(szBuffer),
+ _T("%s -p %u -excp 0x%p -t %u%s"),
+ static_cast<sal_Char*>( aPath ),
+ GetCurrentProcessId(),
+ lpEP,
GetCurrentThreadId(),
fAutoReport ? _T(" -noui -send") : _T(" -noui") );
- if (
- CreateProcess(
- NULL,
- szBuffer,
- NULL,
- NULL,
- FALSE,
+ if (
+ CreateProcess(
+ NULL,
+ szBuffer,
+ NULL,
+ NULL,
+ FALSE,
#ifdef UNICODE
- CREATE_UNICODE_ENVIRONMENT,
+ CREATE_UNICODE_ENVIRONMENT,
#else
0,
#endif
- NULL, NULL, &StartupInfo, &ProcessInfo )
+ NULL, NULL, &StartupInfo, &ProcessInfo )
)
{
DWORD dwExitCode;
WaitForSingleObject( ProcessInfo.hProcess, INFINITE );
if ( GetExitCodeProcess( ProcessInfo.hProcess,
&dwExitCode ) && 0 == dwExitCode )
-
+
fSuccess = TRUE;
}
@@ -233,12 +231,12 @@ static BOOL WINAPI IsWin95A(void)
if ( GetVersionEx( &ovi ) )
/* See MSDN January 2000 documentation of GetVersionEx */
- return (ovi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
- (ovi.dwMajorVersion <= 4) &&
- (ovi.dwMinorVersion == 0) &&
+ return (ovi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
+ (ovi.dwMajorVersion <= 4) &&
+ (ovi.dwMinorVersion == 0) &&
(ovi.dwBuildNumber == 0x040003B6);
- /* Something wrent wrong. So assume we have an older operating prior
Win95 */
+ /* Something went wrong. So assume we have an older operating prior
Win95 */
return TRUE;
}
@@ -258,33 +256,33 @@ static long WINAPI
SignalHandlerFunction(LPEXCEPTION_POINTERS lpEP)
switch (lpEP->ExceptionRecord->ExceptionCode)
{
- /* Transform unhandled exceptions into access violations.
+ /* Transform unhandled exceptions into access violations.
Microsoft C++ compiler (add more for other compilers if
necessary).
*/
- case EXCEPTION_MSC_CPP_EXCEPTION:
- case EXCEPTION_ACCESS_VIOLATION:
+ case EXCEPTION_MSC_CPP_EXCEPTION:
+ case EXCEPTION_ACCESS_VIOLATION:
Info.Signal = osl_Signal_AccessViolation;
bRaiseCrashReporter = sal_True;
- break;
+ break;
- case EXCEPTION_INT_DIVIDE_BY_ZERO:
+ case EXCEPTION_INT_DIVIDE_BY_ZERO:
Info.Signal = osl_Signal_IntegerDivideByZero;
bRaiseCrashReporter = sal_True;
- break;
+ break;
- case EXCEPTION_FLT_DIVIDE_BY_ZERO:
+ case EXCEPTION_FLT_DIVIDE_BY_ZERO:
Info.Signal = osl_Signal_FloatDivideByZero;
bRaiseCrashReporter = sal_True;
- break;
+ break;
- case EXCEPTION_BREAKPOINT:
+ case EXCEPTION_BREAKPOINT:
Info.Signal = osl_Signal_DebugBreak;
- break;
-
+ break;
+
default:
Info.Signal = osl_Signal_System;
bRaiseCrashReporter = sal_True;
- break;
+ break;
}
if ( !bNested )
@@ -315,8 +313,8 @@ static long WINAPI
SignalHandlerFunction(LPEXCEPTION_POINTERS lpEP)
SetErrorMode(SEM_NOGPFAULTERRORBOX);
exit(255);
break;
- default:
- break;
+ default:
+ break;
}
return (EXCEPTION_CONTINUE_EXECUTION);
@@ -337,12 +335,12 @@ oslSignalHandler SAL_CALL
osl_addSignalHandler(oslSignalHandlerFunction Handler,
pHandler = reinterpret_cast< oslSignalHandlerImpl* >( calloc( 1,
sizeof(oslSignalHandlerImpl) ) );
if (pHandler != NULL)
- {
+ {
pHandler->Handler = Handler;
pHandler->pData = pData;
osl_acquireMutex(SignalListMutex);
-
+
pHandler->pNext = SignalList;
SignalList = pHandler;
@@ -392,7 +390,7 @@ sal_Bool SAL_CALL osl_removeSignalHandler(oslSignalHandler
Handler)
pPrevious = pHandler;
pHandler = pHandler->pNext;
}
-
+
osl_releaseMutex(SignalListMutex);
return (sal_False);
@@ -416,7 +414,7 @@ oslSignalAction SAL_CALL osl_raiseSignal(sal_Int32
UserSignal, void* UserData)
Info.UserData = UserData;
Action = CallSignalHandler(&Info);
-
+
osl_releaseMutex(SignalListMutex);
return (Action);
@@ -475,3 +473,5 @@ sal_Bool SAL_CALL osl_setErrorReporting( sal_Bool bEnable )
return bOld;
}
+
+/* vim: set noet sw=4 ts=4: */
diff --git a/main/sal/osl/w32/tempfile.cxx b/main/sal/osl/w32/tempfile.cxx
index c18c6a687e..0281110b2c 100644
--- a/main/sal/osl/w32/tempfile.cxx
+++ b/main/sal/osl/w32/tempfile.cxx
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,20 +7,18 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
-
-
#define UNICODE
#define _UNICODE
#define _WIN32_WINNT_0x0500
@@ -40,12 +38,12 @@
//#####################################################
#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
+// 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)));
#else
#define STACK_ALLOC(p, t, n) __try {(p) =
reinterpret_cast<t*>(_alloca((n)*sizeof(t)));} \
- __except(EXCEPTION_EXECUTE_HANDLER) {(p) = 0;}
+
__except(EXCEPTION_EXECUTE_HANDLER) {(p) = 0;}
#endif
extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle(HANDLE
hFile, sal_uInt32 uFlags);
@@ -53,33 +51,33 @@ extern "C" oslFileHandle SAL_CALL
osl_createFileHandleFromOSHandle(HANDLE hFile,
//#####################################################
// Temp file functions
//#####################################################
-
+
static oslFileError osl_setup_base_directory_impl_(
rtl_uString* pustrDirectoryURL,
rtl_uString** ppustr_base_dir)
-{
+{
rtl_uString* dir_url = 0;
- rtl_uString* dir = 0;
+ rtl_uString* dir = 0;
oslFileError error = osl_File_E_None;
-
+
if (pustrDirectoryURL)
- rtl_uString_assign(&dir_url, pustrDirectoryURL);
- else
- error = osl_getTempDirURL(&dir_url);
+ rtl_uString_assign(&dir_url, pustrDirectoryURL);
+ else
+ error = osl_getTempDirURL(&dir_url);
- if (osl_File_E_None == error)
+ if (osl_File_E_None == error)
{
- error = _osl_getSystemPathFromFileURL(dir_url, &dir, sal_False);
- rtl_uString_release(dir_url);
+ error = _osl_getSystemPathFromFileURL(dir_url, &dir, sal_False);
+ rtl_uString_release(dir_url);
}
-
+
if (osl_File_E_None == error )
{
- rtl_uString_assign(ppustr_base_dir, dir);
+ rtl_uString_assign(ppustr_base_dir, dir);
rtl_uString_release(dir);
}
-
- return error;
+
+ return error;
}
//#####################################################
@@ -91,21 +89,21 @@ static oslFileError osl_setup_createTempFile_impl_(
sal_Bool* b_delete_on_close)
{
oslFileError osl_error;
-
+
OSL_PRECOND(((0 != pHandle) || (0 != ppustrTempFileURL)), "Invalid
parameter!");
-
- if ((0 == pHandle) && (0 == ppustrTempFileURL))
+
+ if ((0 == pHandle) && (0 == ppustrTempFileURL))
{
osl_error = osl_File_E_INVAL;
}
else
- {
+ {
osl_error = osl_setup_base_directory_impl_(
pustrDirectoryURL, ppustr_base_dir);
-
+
*b_delete_on_close = (sal_Bool)(0 == ppustrTempFileURL);
}
-
+
return osl_error;
}
@@ -114,16 +112,16 @@ static oslFileError osl_win32_GetTempFileName_impl_(
rtl_uString* base_directory, LPWSTR temp_file_name)
{
oslFileError osl_error = osl_File_E_None;
-
+
if (0 == GetTempFileNameW(
reinterpret_cast<LPCWSTR>(rtl_uString_getStr(base_directory)),
L"",
0,
temp_file_name))
- {
+ {
osl_error = oslTranslateFileError(GetLastError());
}
-
+
return osl_error;
}
@@ -133,123 +131,123 @@ static sal_Bool osl_win32_CreateFile_impl_(
{
DWORD flags = FILE_ATTRIBUTE_NORMAL;
HANDLE hFile;
-
+
OSL_ASSERT(p_handle);
-
+
if (b_delete_on_close)
flags |= FILE_FLAG_DELETE_ON_CLOSE;
-
+
hFile = CreateFileW(
file_name,
GENERIC_READ | GENERIC_WRITE,
- 0,
- NULL,
- TRUNCATE_EXISTING,
+ 0,
+ NULL,
+ TRUNCATE_EXISTING,
flags,
NULL);
-
+
// @@@ ERROR HANDLING @@@
- if (IsValidHandle(hFile))
+ if (IsValidHandle(hFile))
*p_handle = osl_createFileHandleFromOSHandle(hFile,
osl_File_OpenFlag_Read | osl_File_OpenFlag_Write);
-
+
return (sal_Bool)IsValidHandle(hFile);
}
-//#############################################
+//#############################################
static oslFileError osl_createTempFile_impl_(
- rtl_uString* base_directory,
+ rtl_uString* base_directory,
LPWSTR tmp_name,
sal_Bool b_delete_on_close,
oslFileHandle* pHandle,
rtl_uString** ppustrTempFileURL)
{
oslFileError osl_error;
-
+
do
- {
+ {
osl_error = osl_win32_GetTempFileName_impl_(base_directory,
tmp_name);
-
- /* if file could not be opened try again */
-
- if ((osl_File_E_None != osl_error) || (0 == pHandle) ||
- osl_win32_CreateFile_impl_(tmp_name, b_delete_on_close,
pHandle))
+
+ /* if file could not be opened try again */
+
+ if ((osl_File_E_None != osl_error) || (0 == pHandle) ||
+ osl_win32_CreateFile_impl_(tmp_name, b_delete_on_close,
pHandle))
break;
-
+
} while(1); // try until success
-
- if ((osl_File_E_None == osl_error) && !b_delete_on_close)
+
+ if ((osl_File_E_None == osl_error) && !b_delete_on_close)
{
- rtl_uString* pustr = 0;
- rtl_uString_newFromStr(&pustr, reinterpret_cast<const
sal_Unicode*>(tmp_name));
+ rtl_uString* pustr = 0;
+ rtl_uString_newFromStr(&pustr, reinterpret_cast<const
sal_Unicode*>(tmp_name));
osl_getFileURLFromSystemPath(pustr, ppustrTempFileURL);
rtl_uString_release(pustr);
}
-
+
return osl_error;
}
-
+
//#############################################
-oslFileError SAL_CALL osl_createTempFile(
- rtl_uString* pustrDirectoryURL,
- oslFileHandle* pHandle,
- rtl_uString** ppustrTempFileURL)
+oslFileError SAL_CALL osl_createTempFile(
+ rtl_uString* pustrDirectoryURL,
+ oslFileHandle* pHandle,
+ rtl_uString** ppustrTempFileURL)
{
- rtl_uString* base_directory = 0;
- LPWSTR tmp_name;
- sal_Bool b_delete_on_close;
- oslFileError osl_error;
-
- osl_error = osl_setup_createTempFile_impl_(
- pustrDirectoryURL,
- pHandle,
- ppustrTempFileURL,
- &base_directory,
- &b_delete_on_close);
-
- if (osl_File_E_None != osl_error)
- return osl_error;
-
- /* allocate enough space on the stack, the file name can not be longer
than MAX_PATH */
- STACK_ALLOC(tmp_name, WCHAR, (rtl_uString_getLength(base_directory) +
MAX_PATH));
-
- if (tmp_name)
- {
- osl_createTempFile_impl_(
- base_directory,
- tmp_name,
- b_delete_on_close,
- pHandle,
- ppustrTempFileURL);
- }
- else // stack alloc failed
- {
- osl_error = osl_File_E_NOMEM;
- }
-
- if (base_directory)
- rtl_uString_release(base_directory);
-
- return osl_error;
+ rtl_uString* base_directory = 0;
+ LPWSTR tmp_name;
+ sal_Bool b_delete_on_close;
+ oslFileError osl_error;
+
+ osl_error = osl_setup_createTempFile_impl_(
+ pustrDirectoryURL,
+ pHandle,
+ ppustrTempFileURL,
+ &base_directory,
+ &b_delete_on_close);
+
+ if (osl_File_E_None != osl_error)
+ return osl_error;
+
+ /* allocate enough space on the stack, the file name can not be longer
than MAX_PATH */
+ STACK_ALLOC(tmp_name, WCHAR, (rtl_uString_getLength(base_directory) +
MAX_PATH));
+
+ if (tmp_name)
+ {
+ osl_createTempFile_impl_(
+ base_directory,
+ tmp_name,
+ b_delete_on_close,
+ pHandle,
+ ppustrTempFileURL);
+ }
+ else // stack alloc failed
+ {
+ osl_error = osl_File_E_NOMEM;
+ }
+
+ if (base_directory)
+ rtl_uString_release(base_directory);
+
+ return osl_error;
}
//#############################################
oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir)
{
- ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
+ ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
LPWSTR lpBuffer = ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer);
DWORD nBufferLength = aBuffer.getBufSizeInSymbols() - 1;
DWORD nLength;
oslFileError error;
- nLength = GetTempPathW( aBuffer.getBufSizeInSymbols(), lpBuffer );
+ nLength = GetTempPathW( aBuffer.getBufSizeInSymbols(), lpBuffer );
- if ( nLength > nBufferLength )
- {
- // the provided path has invalid length
- error = osl_File_E_NOENT;
- }
- else if ( nLength )
+ if ( nLength > nBufferLength )
+ {
+ // the provided path has invalid length
+ error = osl_File_E_NOENT;
+ }
+ else if ( nLength )
{
rtl_uString *ustrTempPath = NULL;
@@ -267,3 +265,5 @@ oslFileError SAL_CALL osl_getTempDirURL(rtl_uString**
pustrTempDir)
return error;
}
+
+/* vim: set noet sw=4 ts=4: */