diff options
-rw-r--r-- | bridges/test/java_uno/any/makefile.mk | 5 | ||||
-rw-r--r-- | cppu/source/typelib/static_types.cxx | 32 | ||||
-rw-r--r-- | cppu/source/uno/lbenv.cxx | 22 | ||||
-rw-r--r-- | jvmaccess/source/classpath.cxx | 14 | ||||
-rw-r--r-- | pyuno/zipcore/python.cxx | 9 | ||||
-rw-r--r-- | pyuno/zipcore/python.sh | 4 | ||||
-rw-r--r-- | registry/inc/registry/registry.h | 42 | ||||
-rw-r--r-- | registry/inc/registry/registry.hxx | 34 | ||||
-rw-r--r-- | registry/inc/registry/regtype.h | 18 | ||||
-rw-r--r-- | registry/source/keyimpl.cxx | 195 | ||||
-rw-r--r-- | registry/source/keyimpl.hxx | 30 | ||||
-rw-r--r-- | registry/source/regimpl.cxx | 480 | ||||
-rw-r--r-- | registry/source/regimpl.hxx | 56 | ||||
-rw-r--r-- | registry/source/regkey.cxx | 62 | ||||
-rw-r--r-- | registry/source/regmap.hxx | 73 | ||||
-rw-r--r-- | registry/tools/checksingleton.cxx | 3 | ||||
-rw-r--r-- | registry/tools/regcompare.cxx | 6 | ||||
-rw-r--r-- | sal/osl/unx/module.c | 12 | ||||
-rw-r--r-- | sal/typesconfig/typesconfig.c | 98 | ||||
-rw-r--r-- | stoc/source/javavm/javavm.cxx | 13 |
20 files changed, 213 insertions, 995 deletions
diff --git a/bridges/test/java_uno/any/makefile.mk b/bridges/test/java_uno/any/makefile.mk index e2df011e4631..d02c5fc4d93c 100644 --- a/bridges/test/java_uno/any/makefile.mk +++ b/bridges/test/java_uno/any/makefile.mk @@ -115,8 +115,9 @@ $(OUT)$/bin$/TestRemote$(SCRIPTEXT) : $(JAVACLASSFILES) $(OUT)$/bin$/TestJni$(SCRIPTEXT) : $(JAVACLASSFILES) -rm -f $@ - echo java -classpath .$(PATH_SEPERATOR)..$/class$(PATH_SEPERATOR)$(EXEC_CLASSPATH) \ - test.java_uno.anytest.TestJni >> $@ + echo java -classpath \ + .$(PATH_SEPERATOR)..$/class$(PATH_SEPERATOR)$(EXEC_CLASSPATH) \ + -Djava.library.path=..$/lib test.java_uno.anytest.TestJni >> $@ $(GIVE_EXEC_RIGHTS) $@ $(BIN)$/test_java_uno_anytest.rdb : types.idl diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx index d2b859b93cc8..f0787c19ae5c 100644 --- a/cppu/source/typelib/static_types.cxx +++ b/cppu/source/typelib/static_types.cxx @@ -39,6 +39,7 @@ #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/memory.h> +#include <rtl/instance.hxx> #include <typelib/typedescription.h> @@ -114,19 +115,10 @@ static inline sal_Int32 newAlignedSize( } //-------------------------------------------------------------------------------------------------- -static Mutex & typelib_getStaticInitMutex() SAL_THROW( () ) + +namespace { - static Mutex * s_pMutex = 0; - if (! s_pMutex) - { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (! s_pMutex) - { - static Mutex s_aMutex; - s_pMutex = &s_aMutex; - } - } - return *s_pMutex; + struct typelib_StaticInitMutex : public rtl::Static< Mutex, typelib_StaticInitMutex > {}; } // !for NOT REALLY WEAK TYPES only! @@ -159,7 +151,7 @@ typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_getByTypeClass( if (! s_aTypes[eTypeClass]) { - MutexGuard aGuard( typelib_getStaticInitMutex() ); + MutexGuard aGuard( typelib_StaticInitMutex::get() ); if (! s_aTypes[eTypeClass]) { static const char * s_aTypeNames[] = { @@ -332,7 +324,7 @@ void SAL_CALL typelib_static_type_init( { if (! *ppRef) { - MutexGuard aGuard( typelib_getStaticInitMutex() ); + MutexGuard aGuard( typelib_StaticInitMutex::get() ); if (! *ppRef) { OUString aTypeName( OUString::createFromAscii( pTypeName ) ); @@ -354,7 +346,7 @@ void SAL_CALL typelib_static_sequence_type_init( { if (! *ppRef) { - MutexGuard aGuard( typelib_getStaticInitMutex() ); + MutexGuard aGuard( typelib_StaticInitMutex::get() ); if (! *ppRef) { OUStringBuffer aBuf( 32 ); @@ -398,7 +390,7 @@ void init( if (! *ppRef) { - MutexGuard aGuard( typelib_getStaticInitMutex() ); + MutexGuard aGuard( typelib_StaticInitMutex::get() ); if (! *ppRef) { OSL_ASSERT( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(eTypeClass) ); @@ -514,7 +506,7 @@ void SAL_CALL typelib_static_mi_interface_type_init( { if (! *ppRef) { - MutexGuard aGuard( typelib_getStaticInitMutex() ); + MutexGuard aGuard( typelib_StaticInitMutex::get() ); if (! *ppRef) { OSL_ASSERT( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_INTERFACE) ); @@ -579,7 +571,7 @@ void SAL_CALL typelib_static_enum_type_init( { if (! *ppRef) { - MutexGuard aGuard( typelib_getStaticInitMutex() ); + MutexGuard aGuard( typelib_StaticInitMutex::get() ); if (! *ppRef) { OSL_ASSERT( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_ENUM) ); @@ -621,7 +613,7 @@ void SAL_CALL typelib_static_array_type_init( { if (! *ppRef) { - MutexGuard aGuard( typelib_getStaticInitMutex() ); + MutexGuard aGuard( typelib_StaticInitMutex::get() ); if (! *ppRef) { OUStringBuffer aBuf( 32 ); @@ -693,7 +685,7 @@ void SAL_CALL typelib_static_union_type_init( { if (! *ppRef) { - MutexGuard aGuard( typelib_getStaticInitMutex() ); + MutexGuard aGuard( typelib_StaticInitMutex::get() ); if (! *ppRef) { OSL_ASSERT( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_UNION) ); diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx index 90fa774764a9..b0c31a653162 100644 --- a/cppu/source/uno/lbenv.cxx +++ b/cppu/source/uno/lbenv.cxx @@ -44,6 +44,7 @@ #include "rtl/string.hxx" #include "rtl/ustring.hxx" #include "rtl/ustrbuf.hxx" +#include "rtl/instance.hxx" #include "typelib/typedescription.h" #include "uno/dispatcher.h" #include "uno/environment.h" @@ -151,20 +152,9 @@ struct EnvironmentsData uno_memAlloc memAlloc, const OUString & rEnvDcp ); }; -//------------------------------------------------------------------------------ -static EnvironmentsData & getEnvironmentsData() +namespace { - static EnvironmentsData * s_p = 0; - if (! s_p) - { - ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); - if (! s_p) - { - static EnvironmentsData s_obj; - s_p = &s_obj; - } - } - return *s_p; + struct theEnvironmentsData : public rtl::Static< EnvironmentsData, theEnvironmentsData > {}; } //============================================================================== @@ -610,7 +600,7 @@ static void SAL_CALL defenv_harden( uno_DefaultEnvironment * that = (uno_DefaultEnvironment *)pEnv; { - ::osl::MutexGuard guard( getEnvironmentsData().mutex ); + ::osl::MutexGuard guard( theEnvironmentsData::get().mutex ); if (1 == ::osl_incrementInterlockedCount( &that->nRef )) // is dead { that->nRef = 0; @@ -1160,7 +1150,7 @@ void SAL_CALL uno_direct_getEnvironment( OSL_ENSURE( ppEnv, "### null ptr!" ); OUString const & rEnvDcp = OUString::unacquired( &pEnvDcp ); - EnvironmentsData & rData = getEnvironmentsData(); + EnvironmentsData & rData = theEnvironmentsData::get(); ::osl::MutexGuard guard( rData.mutex ); rData.getEnvironment( ppEnv, rEnvDcp, pContext ); @@ -1181,7 +1171,7 @@ void SAL_CALL uno_getRegisteredEnvironments( rtl_uString * pEnvDcp ) SAL_THROW_EXTERN_C() { - EnvironmentsData & rData = getEnvironmentsData(); + EnvironmentsData & rData = theEnvironmentsData::get(); ::osl::MutexGuard guard( rData.mutex ); rData.getRegisteredEnvironments( diff --git a/jvmaccess/source/classpath.cxx b/jvmaccess/source/classpath.cxx index a4ff354ecf97..61d3fc9d4eae 100644 --- a/jvmaccess/source/classpath.cxx +++ b/jvmaccess/source/classpath.cxx @@ -40,7 +40,6 @@ #include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" -#include "com/sun/star/uri/ExternalUriReferenceTranslator.hpp" #include "com/sun/star/uri/UriReferenceFactory.hpp" #include "com/sun/star/uri/XVndSunStarExpandUrlReference.hpp" #include "com/sun/star/util/XMacroExpander.hpp" @@ -101,19 +100,6 @@ void * ::jvmaccess::ClassPath::doTranslateToUrls( css::uno::Reference< css::uno::XInterface >()); } } - if (url.getLength() != 0) { - url = css::uri::ExternalUriReferenceTranslator::create( - context)->translateToExternal(url); - if (url.getLength() == 0) { - throw css::uno::RuntimeException( - ::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.uri." - "ExternalUriReferenceTranslator." - "translateToExternal failed")), - css::uno::Reference< css::uno::XInterface >()); - } - } jvalue arg; arg.l = env->NewString( static_cast< jchar const * >(url.getStr()), diff --git a/pyuno/zipcore/python.cxx b/pyuno/zipcore/python.cxx index 412f75a84598..355921805dbb 100644 --- a/pyuno/zipcore/python.cxx +++ b/pyuno/zipcore/python.cxx @@ -91,6 +91,15 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) { exit(EXIT_FAILURE); } wchar_t * pathEnd = tools::filename(path); + *pathEnd = L'\0'; + n = GetEnvironmentVariableW(L"UNO_PATH", NULL, 0); + if (n == 0) { + if (GetLastError() != ERROR_ENVVAR_NOT_FOUND || + !SetEnvironmentVariableW(L"UNO_PATH", path)) + { + exit(EXIT_FAILURE); + } + } wchar_t bootstrap[MY_LENGTH(L"vnd.sun.star.pathname:") + MAX_PATH] = L"vnd.sun.star.pathname:"; //TODO: overflow wchar_t * bootstrapEnd = tools::buildPath( diff --git a/pyuno/zipcore/python.sh b/pyuno/zipcore/python.sh index 5195f68e24aa..199ed9c0eadb 100644 --- a/pyuno/zipcore/python.sh +++ b/pyuno/zipcore/python.sh @@ -51,6 +51,10 @@ export PATH LD_LIBRARY_PATH=$sd_prog/../basis-link/program:$sd_prog/../basis-link/ure-link/lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH} export LD_LIBRARY_PATH +# Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: +: ${UNO_PATH=$sd_prog} +export UNO_PATH + # Set URE_BOOTSTRAP so that "uno.getComponentContext()" bootstraps a complete # OOo UNO environment: : ${URE_BOOTSTRAP=vnd.sun.star.pathname:$sd_prog/fundamentalrc} diff --git a/registry/inc/registry/registry.h b/registry/inc/registry/registry.h index 294aaa0b3cad..99b314b5767c 100644 --- a/registry/inc/registry/registry.h +++ b/registry/inc/registry/registry.h @@ -281,29 +281,21 @@ RegError REGISTRY_CALLTYPE reg_freeValueList(RegValueType valueType, RegValue pValueList, sal_uInt32 len); -/** This function creates a link with the specified link name and link target. +/** This function used to create a link. - Links in the registry are similar to links in the UNIX fielsystem. If a link will be opened, - the link target will be resolved and the key speciefied by the link target will be opened. - @param hKey identifies a currently open key. The link which will be created is a subkey - of the key identified by hKey. - @param linkName points to a null terminated string specifying the name of the new link. - @param linkTarget points to a null terminated string specifying the link target of the new link. - The linktarget must specify a valid name of an existing key. The linktarget itself - can contain links in the full qualified name. All links will be resolved if the - link will be opened. - @return REG_NO_ERROR if succeeds else an error code. + @obsolete Links are no longer supported. + + @return REG_INVALID_LINK */ RegError REGISTRY_CALLTYPE reg_createLink(RegKeyHandle hKey, rtl_uString* linkName, rtl_uString* linkTarget); -/** This function deletes a link with the specified linkname. +/** This function used to delete a link. - @param hKey identifies a currently open key. The link which will be deleted is a subkey - of the key identified by hKey. - @param linkName points to a null terminated string specifying the name of the link. - @return REG_NO_ERROR if succeeds else an error code. + @obsolete Links are no longer supported. + + @return REG_INVALID_LINK */ RegError REGISTRY_CALLTYPE reg_deleteLink(RegKeyHandle hKey, rtl_uString* linkName); @@ -312,7 +304,7 @@ RegError REGISTRY_CALLTYPE reg_deleteLink(RegKeyHandle hKey, The registry differentiates two possible types: - RG_KEYTYPE represents a real key - - RG_LINKTYPE represents a link + - RG_LINKTYPE used to represent a link (no longer used) @param keyName points to a null terminated string specifying the name of the key which keytype will be returned. @param pKeyType returns the type of the key. @@ -322,24 +314,24 @@ RegError REGISTRY_CALLTYPE reg_getKeyType(RegKeyHandle hKey, rtl_uString* keyName, RegKeyType* pKeyType); -/** This function returns the linktarget of a link. +/** This function used to return the linktarget of a link. - @param linkName points to a null terminated string specifying the name of the link which - linktarget will be returned. - @param pLinkTarget contains the linktarget if succeeds else an empty string. - @return REG_NO_ERROR if succeeds else an error code. + @obsolete Links are no longer supported. + + @return REG_INVALID_LINK */ RegError REGISTRY_CALLTYPE reg_getLinkTarget(RegKeyHandle hKey, rtl_uString* linkName, rtl_uString** pLinkTarget); -/** This function resolves all or only the first link of a keyname. +/** This function resolves a keyname. and returns the resolved keyName in pResolvedName. @param hKey identifies a currently open key. The key specified by keyName is a subkey of the key identified by hKey. @param keyName points to a null terminated string specifying the relativ name of a key. - The name of hKey together with keyName will be resolved from links. + The name of hKey together with keyName will be generated. + @param firstLinkOnly ignored @return REG_NO_ERROR if succeeds else an error code. */ RegError REGISTRY_CALLTYPE reg_getResolvedKeyName(RegKeyHandle hKey, @@ -473,7 +465,7 @@ RegError REGISTRY_CALLTYPE reg_destroyRegistry(RegHandle hRegistry, /** This function reports the complete registry information of a key and all of its subkeys. - All information which are available (keynames, value types, values, linknames, linktargets, ...) + All information which are available (keynames, value types, values, ...) will be printed to stdout for report issues only. @param hKey identifies a currently open key which content will be reported. @return REG_NO_ERROR if succeeds else an error code. diff --git a/registry/inc/registry/registry.hxx b/registry/inc/registry/registry.hxx index c1c4d106fc8f..e3ee4574023d 100644 --- a/registry/inc/registry/registry.hxx +++ b/registry/inc/registry/registry.hxx @@ -219,7 +219,7 @@ public: /** This function reports the complete registry information of a key and all of its subkeys. - All information which are available (keynames, value types, values, linknames, linktargets, ...) + All information which are available (keynames, value types, values, ...) will be printed to stdout for report issues only. @param rKey references a currently open key which content will be reported. @return REG_NO_ERROR if succeeds else an error code. @@ -597,46 +597,46 @@ public: inline RegError getUnicodeListValue(const ::rtl::OUString& keyName, RegistryValueList<sal_Unicode*>& rValueList); - /** creates a new link with the specified name and target. + /** used to create a link. - @param linkName specifies the name of link - @param linkTarget specifies a full qualified keyname as target for the link. - @return REG_NO_ERROR if succeeds else an error code. + @obsolete Links are no longer supported. + + @return REG_INVALID_LINK */ inline RegError createLink(const ::rtl::OUString& linkName, const ::rtl::OUString& linkTarget); - /** deletes an existing link. + /** used to delete a link. - @param linkName specifies the name of link - @return REG_NO_ERROR if succeeds else an error code. + @obsolete Links are no longer supported. + + @return REG_INVALID_LINK */ inline RegError deleteLink(const ::rtl::OUString& linkName); - /** returns the type of the specified key if it is a link or a real key. + /** returns the type of the specified key. @param name specifies the name of the key or link. - @param pKeyType returns the type of the key. + @param pKeyType returns the type of the key (always RG_KEYTYPE). @return REG_NO_ERROR if succeeds else an error code. */ inline RegError getKeyType(const ::rtl::OUString& name, RegKeyType* pKeyType) const; - /** returns the target of the specified link. + /** used to return the target of a link. - @param linkName specifies the name of link. - @param rLinkTarget returns the target keyname of the link. - @return REG_NO_ERROR if succeeds else an error code. + @obsolete Links are no longer supported. + + @return REG_INVALID_LINK */ inline RegError getLinkTarget(const ::rtl::OUString& linkName, ::rtl::OUString& rLinkTarget) const; - /** resolves all or only the first link of a keyname. + /** resolves a keyname. - The function resolves either only the first link or it resolves all links - which exists in the keyname or recursive in the resolved parts. @param keyName specifies the name of the key which will be resolved relativ to this key. The resolved name will be prefixed with the name of this key. + @param firstLinkOnly ignored @return REG_NO_ERROR if succeeds else an error code. */ inline RegError getResolvedKeyName(const ::rtl::OUString& keyName, diff --git a/registry/inc/registry/regtype.h b/registry/inc/registry/regtype.h index 7e4ec33adab4..7e22f0cd4d12 100644 --- a/registry/inc/registry/regtype.h +++ b/registry/inc/registry/regtype.h @@ -64,13 +64,13 @@ typedef sal_uInt16 RegAccessMode; The registry differs between normal keys which can contain subkeys or a value and link keys which navigate over the linktarget to an existing - other key. The mechanism is similar to links in a UNIX filesystem. + other key (which are no longer supported). */ enum RegKeyType { /// represents a real key RG_KEYTYPE, - /// represents a link + /// represents a link (which is no longer supported) RG_LINKTYPE }; @@ -158,15 +158,19 @@ enum RegError */ REG_MERGE_CONFLICT, - /// a recursion was detected resolving different link targets. + /** a recursion was detected resolving different link targets (no longer + used). + */ REG_DETECT_RECURSION, - /// the link is invalid and can not be resolved. + /** the link is invalid and can not be resolved (now used by all + link-related operations, as links are no longer supported). + */ REG_INVALID_LINK, - /// the specified linkname is not valid. + /// the specified linkname is not valid (no longer used). REG_INVALID_LINKNAME, - /// the linknane is not valid. + /// the linknane is not valid (no longer used). REG_INVALID_LINKTARGET, - /// the link target points to a nonexisting key. + /// the link target points to a nonexisting key (no longer used). REG_LINKTARGET_NOT_EXIST, /// the reserved buffer for the resolved keyname is to small. REG_BUFFERSIZE_TOSMALL diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx index 8b9c6ce00de2..f8de7e20b148 100644 --- a/registry/source/keyimpl.cxx +++ b/registry/source/keyimpl.cxx @@ -31,13 +31,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_registry.hxx" -#ifndef __REFLCNST_HXX__ #include "reflcnst.hxx" -#endif #include "keyimpl.hxx" #include <rtl/alloc.h> #include <rtl/memory.h> +#include "rtl/ustrbuf.hxx" + +namespace { static char const VALUE_PREFIX[] = "$VL_"; } //********************************************************************* // ORegKey() @@ -46,24 +47,8 @@ ORegKey::ORegKey(const OUString& keyName, ORegistry* pReg) : m_refCount(1) , m_name(keyName) , m_bDeleted(sal_False) - , m_isLink(sal_False) , m_pRegistry(pReg) -{ - if (pReg) - { - m_storeFile = pReg->getStoreFile(); - } - - checkLink(); -} - -//********************************************************************* -// ~ORegKey() -// -ORegKey::~ORegKey() -{ -} - +{} //********************************************************************* // createKey @@ -77,9 +62,9 @@ RegError ORegKey::createKey(const OUString& keyName, RegKeyHandle* phNewKey) //********************************************************************* // openKey // -RegError ORegKey::openKey(const OUString& keyName, RegKeyHandle* phOpenKey, RESOLVE eResolve) +RegError ORegKey::openKey(const OUString& keyName, RegKeyHandle* phOpenKey) { - return (m_pRegistry->openKey(this, keyName, phOpenKey, eResolve)); + return (m_pRegistry->openKey(this, keyName, phOpenKey)); } @@ -172,7 +157,7 @@ RegError ORegKey::getKeyNames(const OUString& keyName, if (keyName.getLength()) { - _ret = openKey(keyName, (RegKeyHandle*)&pKey, RESOLVE_PART); + _ret = openKey(keyName, (RegKeyHandle*)&pKey); if (_ret) { *pSubKeyNames = NULL; @@ -261,7 +246,7 @@ RegError ORegKey::getValueInfo(const OUString& valueName, RegValueType* pValueTy REG_GUARD(m_pRegistry->m_mutex); - if ( rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) + if ( rValue.create(m_pRegistry->getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) { *pValueType = RG_VALUETYPE_NOT_DEFINED; *pValueSize = 0; @@ -332,7 +317,7 @@ RegError ORegKey::setValue(const OUString& valueName, RegValueType vType, RegVal REG_GUARD(m_pRegistry->m_mutex); - if ( rValue.create(m_storeFile, m_name + m_pRegistry->ROOT , sImplValueName, VALUE_MODE_CREATE) ) + if ( rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT , sImplValueName, VALUE_MODE_CREATE) ) { return REG_SET_VALUE_FAILED; } @@ -402,7 +387,7 @@ RegError ORegKey::setLongListValue(const OUString& valueName, sal_Int32* pValueL REG_GUARD(m_pRegistry->m_mutex); - if (rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) ) + if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) ) { return REG_SET_VALUE_FAILED; } @@ -460,7 +445,7 @@ RegError ORegKey::setStringListValue(const OUString& valueName, sal_Char** pValu REG_GUARD(m_pRegistry->m_mutex); - if (rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) ) + if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) ) { return REG_SET_VALUE_FAILED; } @@ -527,7 +512,7 @@ RegError ORegKey::setUnicodeListValue(const OUString& valueName, sal_Unicode** p REG_GUARD(m_pRegistry->m_mutex); - if (rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) ) + if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) ) { return REG_SET_VALUE_FAILED; } @@ -597,7 +582,7 @@ RegError ORegKey::getValue(const OUString& valueName, RegValue value) const REG_GUARD(m_pRegistry->m_mutex); - if (rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) + if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) { return REG_VALUE_NOT_EXISTS; } @@ -691,7 +676,7 @@ RegError ORegKey::getLongListValue(const OUString& valueName, sal_Int32** pValue REG_GUARD(m_pRegistry->m_mutex); - if (rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) + if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) { pValueList = NULL; *pLen = 0; @@ -788,7 +773,7 @@ RegError ORegKey::getStringListValue(const OUString& valueName, sal_Char*** pVal REG_GUARD(m_pRegistry->m_mutex); - if ( rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) + if ( rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) { pValueList = NULL; *pLen = 0; @@ -894,7 +879,7 @@ RegError ORegKey::getUnicodeListValue(const OUString& valueName, sal_Unicode*** REG_GUARD(m_pRegistry->m_mutex); - if ( rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) + if ( rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) { pValueList = NULL; *pLen = 0; @@ -994,109 +979,25 @@ RegError ORegKey::getKeyType(const OUString& name, RegKeyType* pKeyType) const if ( name.getLength() ) { _ret = ((ORegKey*)this)->openKey( - name, (RegKeyHandle*)&pKey, RESOLVE_PART); + name, (RegKeyHandle*)&pKey); if (_ret) return _ret; - - if (pKey->isLink()) - *pKeyType = RG_LINKTYPE; - ((ORegKey*)this)->closeKey((RegKeyHandle)pKey); return _ret; } else { - if (m_isLink) - *pKeyType = RG_LINKTYPE; - - return _ret; - } -} - -//********************************************************************* -// createLink() -// -RegError ORegKey::createLink(const OUString& linkName, const OUString& linkTarget) -{ - ORegKey* pKey; - RegError _ret = REG_NO_ERROR; - - if ( !linkName.getLength() ) - return REG_INVALID_LINKNAME; - - if ( !linkTarget.getLength() ) - return REG_INVALID_LINKTARGET; - - REG_GUARD(m_pRegistry->m_mutex); - - if (m_pRegistry->openKey(this, linkName, (RegKeyHandle*)&pKey, RESOLVE_PART)) - { - _ret = m_pRegistry->createKey(this, linkName, (RegKeyHandle*)&pKey); - if (_ret) - return _ret; - } else - { - if (!pKey->isLink()) - { - m_pRegistry->closeKey(pKey); - return REG_INVALID_LINK; - } - } - - if ((_ret = pKey->setValue(OUString( RTL_CONSTASCII_USTRINGPARAM("LINK_TARGET") ), - RG_VALUETYPE_UNICODE, (RegValue)linkTarget.getStr(), (linkTarget.getLength()+1)*2))) - { - m_pRegistry->closeKey(pKey); - _ret = m_pRegistry->deleteKey(this, linkName); return _ret; } - - return m_pRegistry->closeKey(pKey); -} - -//********************************************************************* -// deleteLink() -// -RegError ORegKey::deleteLink(const OUString& linkName) -{ - return (m_pRegistry->deleteLink(this, linkName)); -} - -//********************************************************************* -// getLinkTarget() -// -RegError ORegKey::getLinkTarget(const OUString& linkName, OUString& linkTarget) const -{ - ORegKey* pKey; - RegError _ret = REG_NO_ERROR; - - REG_GUARD(m_pRegistry->m_mutex); - - if ( linkName.getLength() ) - { - _ret = ((ORegKey*)this)->openKey( - linkName, (RegKeyHandle*)&pKey, RESOLVE_PART); - if (_ret) - return REG_INVALID_LINK; - - _ret = pKey->getLinkTarget(OUString(), linkTarget); - ((ORegKey*)this)->closeKey((RegKeyHandle)pKey); - return _ret; - } else - { - if (m_isLink) - { - linkTarget = m_link; - return REG_NO_ERROR; - } else - return REG_LINKTARGET_NOT_EXIST; - } } RegError ORegKey::getResolvedKeyName(const OUString& keyName, OUString& resolvedName) { - return - m_pRegistry->getResolvedKeyName((ORegKey*)this, keyName, resolvedName); + if (keyName.getLength() == 0) { + return REG_INVALID_KEYNAME; + } + resolvedName = getFullPath(keyName); + return REG_NO_ERROR; } //********************************************************************* @@ -1124,39 +1025,6 @@ sal_uInt32 ORegKey::countSubKeys() return count; } - -//********************************************************************* -// checkLink() -// -sal_Bool ORegKey::checkLink() -{ - - OUString aPath (m_name); aPath += m_pRegistry->ROOT; - OUString aName (RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX "LINK_TARGET")); - - if (m_storeFile.attrib (aPath, aName, 0, 0) == store_E_None) - { - OUString valueName (RTL_CONSTASCII_USTRINGPARAM("LINK_TARGET")); - RegValueType valueType = RG_VALUETYPE_NOT_DEFINED; - sal_uInt32 valueSize = 0; - - ORegKey* pThis = const_cast<ORegKey*>(this); - if (pThis->getValueInfo (valueName, &valueType, &valueSize) == REG_NO_ERROR) - { - sal_Unicode* value = (sal_Unicode*)rtl_allocateMemory(valueSize); - if (pThis->getValue (valueName, value) == REG_NO_ERROR) - { - m_link = OUString (value); - m_isLink = sal_True; - } - - rtl_freeMemory (value); - return sal_True; - } - } - return sal_False; -} - OStoreDirectory ORegKey::getStoreDir() { OStoreDirectory rStoreDir; @@ -1179,8 +1047,25 @@ OStoreDirectory ORegKey::getStoreDir() accessMode = KEY_MODE_OPENREAD; } - rStoreDir.create(m_storeFile, fullPath, relativName, accessMode); + rStoreDir.create(getStoreFile(), fullPath, relativName, accessMode); return rStoreDir; } +OUString ORegKey::getFullPath(OUString const & path) const { + OSL_ASSERT(m_name.getLength() != 0 && path.getLength() != 0); + OUStringBuffer b(m_name); + if (b.charAt(b.getLength() - 1) == '/') { + if (path[0] == '/') { + b.append(path.getStr() + 1, path.getLength() - 1); + } else { + b.append(path); + } + } else { + if (path[0] != '/') { + b.append(sal_Unicode('/')); + } + b.append(path); + } + return b.makeStringAndClear(); +} diff --git a/registry/source/keyimpl.hxx b/registry/source/keyimpl.hxx index 0325aa08e4b5..4e99696bcd44 100644 --- a/registry/source/keyimpl.hxx +++ b/registry/source/keyimpl.hxx @@ -52,8 +52,7 @@ public: RegError createKey(const OUString& keyName, RegKeyHandle* phNewKey); - RegError openKey(const OUString& keyName, RegKeyHandle* phOpenKey, - RESOLVE eResolve=RESOLVE_FULL); + RegError openKey(const OUString& keyName, RegKeyHandle* phOpenKey); RegError openSubKeys(const OUString& keyName, RegKeyHandle** phOpenSubKeys, @@ -102,23 +101,12 @@ public: sal_Unicode*** pValueList, sal_uInt32* pLen) const; - RegError createLink(const OUString& linkName, const OUString& linkTarget); - - RegError deleteLink(const OUString& linkName); - RegError getKeyType(const OUString& name, RegKeyType* pKeyType) const; - RegError getLinkTarget(const OUString& linkName, - OUString& pLinkTarget) const; - RegError getResolvedKeyName(const OUString& keyName, OUString& resolvedName); -public: - virtual ~ORegKey(); - - sal_Bool isDeleted() const { return m_bDeleted; } @@ -130,17 +118,11 @@ public: sal_uInt32 countSubKeys(); - sal_Bool isLink() const - { return m_isLink; } - - const OUString& getLinkTarget() const - { return m_link; } - ORegistry* getRegistry() const { return m_pRegistry; } const OStoreFile& getStoreFile() const - { return m_storeFile; } + { return m_pRegistry->getStoreFile(); } OStoreDirectory getStoreDir(); @@ -150,17 +132,13 @@ public: sal_uInt32 getRefCount() const { return m_refCount; } - friend class ORegistry; -protected: - sal_Bool checkLink(); + OUString getFullPath(OUString const & path) const; +private: sal_uInt32 m_refCount; OUString m_name; - OUString m_link; sal_Bool m_bDeleted; - sal_Bool m_isLink; ORegistry* m_pRegistry; - OStoreFile m_storeFile; }; diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx index 08db223806e3..86165b42bd1d 100644 --- a/registry/source/regimpl.cxx +++ b/registry/source/regimpl.cxx @@ -31,6 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_registry.hxx" +#include <memory> #include <string.h> #include <stdio.h> @@ -641,10 +642,7 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const OUString& keyName, else pKey = m_openKeyTable[ROOT]; - OUString sFullKeyName = resolveLinks(pKey, keyName); - - if ( !sFullKeyName.getLength() ) - return REG_DETECT_RECURSION; + OUString sFullKeyName = pKey->getFullPath(keyName); if (m_openKeyTable.count(sFullKeyName) > 0) { @@ -688,96 +686,10 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const OUString& keyName, //********************************************************************* // openKey // -static OUString makePath( const OUString & resolvedPath, const OUString &path ) -{ - OUStringBuffer buf(resolvedPath); - if( ! resolvedPath.getLength() || - '/' != resolvedPath[resolvedPath.getLength()-1]) - { - buf.appendAscii( "/" ); - } - - if( path[0] == '/' ) - { - buf.append( path.getStr()+1 ); - } - else - { - buf.append( path ); - } - return buf.makeStringAndClear(); -} - -RegError ORegistry::openKeyWithoutLink( - RegKeyHandle hKey, const OUString& keyName, - RegKeyHandle* phOpenKey) -{ - ORegKey* pKey; - ORegKey* pRet; - storeAccessMode accessMode = KEY_MODE_OPEN; - - *phOpenKey = NULL; - - if ( !keyName.getLength() ) - { - return REG_INVALID_KEYNAME; - } - - if ( isReadOnly() ) - { - accessMode = KEY_MODE_OPENREAD; - } - - REG_GUARD(m_mutex); - - if (hKey) - pKey = (ORegKey*)hKey; - else - pKey = m_openKeyTable[ROOT]; - - OUString sFullKeyName = makePath( pKey->getName(), keyName ); - OUString sFullPath; - OUString sRelativKey; - - sal_Int32 lastIndex = sFullKeyName.lastIndexOf('/'); - sRelativKey = sFullKeyName.copy(lastIndex + 1); - sFullPath = sFullKeyName.copy(0, lastIndex + 1); - - KeyMap::iterator ii = m_openKeyTable.find( sFullKeyName ); - if( ii == m_openKeyTable.end() ) - { - OStoreDirectory rStoreDir; - storeError _err = rStoreDir.create(pKey->getStoreFile(), sFullPath, sRelativKey, accessMode); - - if (_err == store_E_NotExists) - return REG_KEY_NOT_EXISTS; - else - if (_err == store_E_WrongFormat) - return REG_INVALID_KEY; - - if( _err != store_E_None ) - return REG_KEY_NOT_EXISTS; - - pRet = new ORegKey(sFullKeyName, this); - *phOpenKey = pRet; - m_openKeyTable[sFullKeyName] = pRet; - } - else - { - // try to open it directly - pRet = ii->second; - OSL_ASSERT( pRet ); - *phOpenKey = pRet; - pRet->acquire(); - } - return REG_NO_ERROR; -} - RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName, - RegKeyHandle* phOpenKey, RESOLVE eResolve) + RegKeyHandle* phOpenKey) { ORegKey* pKey; - storeAccessMode accessMode = KEY_MODE_OPEN; *phOpenKey = NULL; @@ -786,11 +698,6 @@ RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName, return REG_INVALID_KEYNAME; } - if ( isReadOnly() ) - { - accessMode = KEY_MODE_OPENREAD; - } - REG_GUARD(m_mutex); if (hKey) @@ -798,111 +705,28 @@ RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName, else pKey = m_openKeyTable[ROOT]; - OUString sFullKeyName; - OUString sFullPath; - OUString sRelativKey; - - switch (eResolve) - { - case RESOLVE_FULL: - { - // try the optimistic approach (links aren't recognized) - RegKeyHandle handle = 0; - if( REG_NO_ERROR == openKeyWithoutLink( hKey, keyName,&handle ) ) - { - *phOpenKey = handle; - return REG_NO_ERROR; - } - - sFullKeyName = resolveLinks(pKey, keyName); - if ( !sFullKeyName.getLength() ) - return REG_DETECT_RECURSION; - - sal_Int32 lastIndex = sFullKeyName.lastIndexOf('/'); - sRelativKey = sFullKeyName.copy(lastIndex + 1); - sFullPath = sFullKeyName.copy(0, lastIndex + 1); - } - break; - case RESOLVE_PART: - { - sal_Int32 lastIndex = keyName.lastIndexOf('/'); - if ( lastIndex >= 0 ) - { - OUString sRelativ(keyName.copy(lastIndex)); - OUString tmpKey(keyName.copy(0, lastIndex + 1)); - sFullKeyName = resolveLinks(pKey, tmpKey); - - sFullPath = sFullKeyName; - sFullPath += ROOT; - sFullKeyName += sRelativ; - sRelativKey = sRelativ.copy(1); - } else - { - sFullKeyName = pKey->getName(); - sFullPath = sFullKeyName; - - sRelativKey = keyName; - - if ( sFullKeyName.getLength() > 1 ) - sFullKeyName += ROOT; - - sFullKeyName += keyName; - - if ( sFullPath.getLength() > 1 ) - sFullPath += ROOT; - } - } - break; - case RESOLVE_NOTHING: - { - sFullKeyName = pKey->getName(); - sFullPath = sFullKeyName; - - if (sFullKeyName.getLength() > 1) - sFullKeyName += ROOT; - - sal_Int32 lastIndex = keyName.lastIndexOf('/'); - if ( lastIndex >= 0 && lastIndex < keyName.getLength() ) - { - OUString sRelativ(keyName.copy(lastIndex+1)); - sRelativKey = sRelativ; - sFullKeyName += keyName.copy(1); - - sFullPath = sFullKeyName.copy(0, keyName.lastIndexOf('/') + 1); - } else - { - - sRelativKey += keyName; - sFullKeyName += keyName; - - if ( sFullPath.getLength() > 1 ) - sFullPath += ROOT; - } - } + OUString path(pKey->getFullPath(keyName)); + KeyMap::iterator i(m_openKeyTable.find(path)); + if (i == m_openKeyTable.end()) { + sal_Int32 n = path.lastIndexOf('/') + 1; + switch (OStoreDirectory().create( + pKey->getStoreFile(), path.copy(0, n), path.copy(n), + isReadOnly() ? KEY_MODE_OPENREAD : KEY_MODE_OPEN)) + { + case store_E_NotExists: + return REG_KEY_NOT_EXISTS; + case store_E_WrongFormat: + return REG_INVALID_KEY; + default: break; + } + std::auto_ptr< ORegKey > p(new ORegKey(path, this)); + i = m_openKeyTable.insert(std::make_pair(path, p.get())).first; + p.release(); + } else { + i->second->acquire(); } - - if (m_openKeyTable.count(sFullKeyName) > 0) - { - m_openKeyTable[sFullKeyName]->acquire(); - *phOpenKey = m_openKeyTable[sFullKeyName]; - return REG_NO_ERROR; - } - - OStoreDirectory rStoreDir; - storeError _err = rStoreDir.create(pKey->getStoreFile(), sFullPath, sRelativKey, accessMode); - - if (_err == store_E_NotExists) - return REG_KEY_NOT_EXISTS; - else - if (_err == store_E_WrongFormat) - return REG_INVALID_KEY; - - pKey = new ORegKey(sFullKeyName, this); - - *phOpenKey = pKey; - m_openKeyTable[sFullKeyName] = pKey; - + *phOpenKey = i->second; return REG_NO_ERROR; } @@ -956,18 +780,15 @@ RegError ORegistry::deleteKey(RegKeyHandle hKey, const OUString& keyName) else pKey = m_openKeyTable[ROOT]; - OUString sFullKeyName = resolveLinks(pKey, keyName); - - if ( !sFullKeyName.getLength() ) - return REG_DETECT_RECURSION; + OUString sFullKeyName = pKey->getFullPath(keyName); pKey = m_openKeyTable[ROOT]; - _ret = eraseKey(pKey, sFullKeyName, RESOLVE_NOTHING); + _ret = eraseKey(pKey, sFullKeyName); return _ret; } -RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName, RESOLVE eResolve) +RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName) { RegError _ret = REG_NO_ERROR; @@ -1004,13 +825,13 @@ RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName, RESOLVE eRe } RegKeyHandle hOldKey; - _ret = pKey->openKey(keyName, &hOldKey, eResolve); + _ret = pKey->openKey(keyName, &hOldKey); if (_ret) { return _ret; } - _ret = deleteSubkeysAndValues((ORegKey*)hOldKey, eResolve); + _ret = deleteSubkeysAndValues((ORegKey*)hOldKey); if (_ret) { pKey->closeKey(hOldKey); @@ -1043,7 +864,7 @@ RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName, RESOLVE eRe //********************************************************************* // deleteSubKeys // -RegError ORegistry::deleteSubkeysAndValues(ORegKey* pKey, RESOLVE eResolve) +RegError ORegistry::deleteSubkeysAndValues(ORegKey* pKey) { OStoreDirectory::iterator iter; OUString keyName; @@ -1057,7 +878,7 @@ RegError ORegistry::deleteSubkeysAndValues(ORegKey* pKey, RESOLVE eResolve) if (iter.m_nAttrib & STORE_ATTRIB_ISDIR) { - _ret = eraseKey(pKey, keyName, eResolve); + _ret = eraseKey(pKey, keyName); if (_ret) return _ret; } else @@ -1434,7 +1255,7 @@ RegError ORegistry::checkBlop(OStoreStream& rValue, static sal_uInt32 checkTypeReaders(RegistryTypeReader& reader1, RegistryTypeReader& reader2, - StringSet& nameSet) + std::set< OUString >& nameSet) { sal_uInt32 count=0; sal_uInt16 i; @@ -1463,7 +1284,7 @@ RegError ORegistry::mergeModuleValue(OStoreStream& rTargetValue, { sal_uInt16 index = 0; - StringSet nameSet; + std::set< OUString > nameSet; sal_uInt32 count = checkTypeReaders(reader, reader2, nameSet); if (count != reader.getFieldCount()) @@ -1567,7 +1388,7 @@ RegError ORegistry::loadAndSaveKeys(ORegKey* pTargetKey, } _ret = pSourceKey->openKey( - keyName, (RegKeyHandle*)&pTmpKey, RESOLVE_NOTHING); + keyName, (RegKeyHandle*)&pTmpKey); if (_ret) { return _ret; @@ -1618,33 +1439,6 @@ ORegKey* ORegistry::getRootKey() //********************************************************************* -// getResolvedKeyName() -// -RegError ORegistry::getResolvedKeyName(RegKeyHandle hKey, - const OUString& keyName, - OUString& resolvedName) -{ - ORegKey* pKey; - - if ( !keyName.getLength() ) - return REG_INVALID_KEYNAME; - - REG_GUARD(m_mutex); - - if (hKey) - pKey = (ORegKey*)hKey; - else - pKey = m_openKeyTable[ROOT]; - - resolvedName = resolveLinks(pKey, keyName); - - if ( resolvedName.getLength() ) - return REG_NO_ERROR; - else - return REG_DETECT_RECURSION; -} - -//********************************************************************* // dumpRegistry() // RegError ORegistry::dumpRegistry(RegKeyHandle hKey) const @@ -1696,7 +1490,6 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_ OUString sFullPath(sPath); OString sIndent; storeAccessMode accessMode = VALUE_MODE_OPEN; - sal_Bool bLinkValue = sal_False; if (isReadOnly()) { @@ -1714,12 +1507,6 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_ return REG_VALUE_NOT_EXISTS; } - OUString tmpName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); - tmpName += OUString( RTL_CONSTASCII_USTRINGPARAM("LINK_TARGET") ); - if (sName == tmpName) - { - bLinkValue = sal_True; - } pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); sal_uInt32 rwBytes; @@ -1773,20 +1560,11 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_ { sal_Char* value = (sal_Char*)rtl_allocateMemory(valueSize); readUtf8(pBuffer, value, valueSize); - - if (bLinkValue) - { - fprintf(stdout, "%sKEY: Type = RG_LINKTYPE\n", indent); - fprintf(stdout, "%s LinkTarget = \"%s\"\n", indent, value); - } else - { - fprintf(stdout, "%sValue: Type = RG_VALUETYPE_STRING\n", indent); - fprintf( - stdout, "%s Size = %lu\n", indent, - sal::static_int_cast< unsigned long >(valueSize)); - fprintf(stdout, "%s Data = \"%s\"\n", indent, value); - } - + fprintf(stdout, "%sValue: Type = RG_VALUETYPE_STRING\n", indent); + fprintf( + stdout, "%s Size = %lu\n", indent, + sal::static_int_cast< unsigned long >(valueSize)); + fprintf(stdout, "%s Data = \"%s\"\n", indent, value); rtl_freeMemory(value); } break; @@ -2001,185 +1779,3 @@ RegError ORegistry::dumpKey(const OUString& sPath, const OUString& sName, sal_In return REG_NO_ERROR; } - -//********************************************************************* -// deleteLink() -// -RegError ORegistry::deleteLink(RegKeyHandle hKey, const OUString& linkName) -{ - ORegKey* pKey; - - if ( !linkName.getLength() ) - { - return REG_INVALID_LINKNAME; - } - - REG_GUARD(m_mutex); - - if (hKey) - pKey = (ORegKey*)hKey; - else - pKey = m_openKeyTable[ROOT]; - - OUString tmpPath(linkName); - OUString tmpName; - OUString resolvedPath; - sal_Int32 lastIndex = tmpPath.lastIndexOf('/'); - - if ( lastIndex > 0 && tmpPath.getStr()[0] == '/') - { - tmpName = tmpPath.copy(lastIndex); - - OUString linkPath = tmpPath.copy(0, lastIndex); - - resolvedPath = resolveLinks(pKey, linkPath); - - if ( !resolvedPath.getLength() ) - { - return REG_DETECT_RECURSION; - } - - resolvedPath += tmpName; - } else - { - resolvedPath = pKey->getName(); - - if (lastIndex != 0 && resolvedPath.getLength() > 1) - resolvedPath += ROOT; - - resolvedPath += linkName; - } - - pKey = m_openKeyTable[ROOT]; - - RegKeyType keyType; - RegError ret = REG_NO_ERROR; - ret = pKey->getKeyType(resolvedPath, &keyType); - if (ret) - return ret; - - if (keyType != RG_LINKTYPE) - return REG_INVALID_LINK; - - return eraseKey(pKey, resolvedPath, RESOLVE_PART); -} - -//********************************************************************* -// resolveLinks() -// - -OUString ORegistry::resolveLinks(ORegKey* pKey, const OUString& path) -{ - OUString resolvedPath(pKey->getName()); - sal_Int32 nIndex = 0; - OUString token; - ORegKey* pLink = NULL; - - if ( path.getStr()[0] == '/' ) - nIndex++; - - do - { - token = path.getToken( 0, '/', nIndex ); - if( token.getLength() && resolvedPath.getLength() > 1 ) - resolvedPath += ROOT; - - pLink = resolveLink(pKey, resolvedPath, token); - - if (pLink) - { - OUString tmpName; - sal_Int32 lastIndex; - - while(pLink) - { - if (!insertRecursionLink(pLink)) - { - resetRecursionLinks(); - delete pLink; - return OUString(); - } - - - lastIndex = resolvedPath.lastIndexOf('/'); - tmpName = resolvedPath.copy(lastIndex + 1); - resolvedPath = resolvedPath.copy(0, lastIndex + 1); - - pLink = resolveLink(pKey, resolvedPath, tmpName); - } - - resetRecursionLinks(); - } - } while( nIndex != -1 ); - - return resolvedPath; -} - -//********************************************************************* -// resolveLink() -// -ORegKey* ORegistry::resolveLink(ORegKey* pKey, OUString& resolvedPath, const OUString& name) -{ - OStoreDirectory rStoreDir; - ORegKey* pTmpKey = NULL; - - if ( !rStoreDir.create(pKey->getStoreFile(), resolvedPath, - name, KEY_MODE_OPENREAD) ) - { - resolvedPath += name; - pTmpKey = new ORegKey(resolvedPath, pKey->getRegistry()); - RegKeyType keyType; - if (!pTmpKey->getKeyType(OUString(), &keyType) && (keyType == RG_LINKTYPE)) - { - resolvedPath = pTmpKey->getLinkTarget(); - return pTmpKey; - } - - delete pTmpKey; - return NULL; - } else - { - resolvedPath += name; - - return NULL; - } -} - -sal_Bool ORegistry::insertRecursionLink(ORegKey* pLink) -{ - if (m_recursionList.empty()) - { - m_recursionList.push_back(pLink); - } else - { - LinkList::iterator iter = m_recursionList.begin(); - - while (iter != m_recursionList.end()) - { - if ((*iter)->getName() == pLink->getName()) - return sal_False; - - iter++; - } - m_recursionList.push_back(pLink); - } - - return sal_True; -} - -sal_Bool ORegistry::resetRecursionLinks() -{ - LinkList::iterator iter = m_recursionList.begin(); - - while (iter != m_recursionList.end()) - { - delete *iter; - iter++; - } - - m_recursionList.erase(m_recursionList.begin(), m_recursionList.end()); - - return sal_True; -} - - diff --git a/registry/source/regimpl.hxx b/registry/source/regimpl.hxx index d761709dc50f..c32dcf3527df 100644 --- a/registry/source/regimpl.hxx +++ b/registry/source/regimpl.hxx @@ -31,8 +31,11 @@ #ifndef _REGIMPL_HXX_ #define _REGIMPL_HXX_ +#include <set> + +#include <hash_map> + #include <registry/registry.h> -#include "regmap.hxx" #include <osl/mutex.hxx> #include <store/store.hxx> @@ -51,9 +54,6 @@ #define VALUE_MODE_OPEN store_AccessReadWrite #define VALUE_MODE_OPENREAD store_AccessReadOnly -#define VALUE_PREFIX "$VL_" -#define VALUE_LINKTARGET "$VL_LINK_TARGET" - // 5 Bytes = 1 (Byte fuer den Typ) + 4 (Bytes fuer die Groesse der Daten) #define VALUE_HEADERSIZE 5 #define VALUE_TYPEOFFSET 1 @@ -68,17 +68,7 @@ using namespace rtl; using namespace osl; using namespace store; -enum RESOLVE -{ - // alle Links werden aufgeloest - RESOLVE_FULL, - // alles bis zum letzten TeilStueck wird aufgeloest - RESOLVE_PART, - // kein Link wird aufgeloest - RESOLVE_NOTHING -}; - -class ORegManager; +class ORegKey; class RegistryTypeReader; class ORegistry @@ -105,8 +95,7 @@ public: RegError openKey(RegKeyHandle hKey, const OUString& keyName, - RegKeyHandle* phOpenKey, - RESOLVE eResolve=RESOLVE_FULL); + RegKeyHandle* phOpenKey); RegError closeKey(RegKeyHandle hKey); @@ -124,11 +113,7 @@ public: RegError dumpRegistry(RegKeyHandle hKey) const; - RegError deleteLink(RegKeyHandle hKey, - const OUString& linkName); - -public: - virtual ~ORegistry(); + ~ORegistry(); sal_Bool isReadOnly() const { return m_readOnly; } @@ -144,18 +129,12 @@ public: const OUString& getName() const { return m_name; } - RegError getResolvedKeyName(RegKeyHandle hKey, - const OUString& keyName, - OUString& resolvedName); - friend class ORegKey; -protected: - RegError eraseKey(ORegKey* pKey, - const OUString& keyName, - RESOLVE eResolve=RESOLVE_FULL); - RegError deleteSubkeysAndValues(ORegKey* pKey, - RESOLVE eResolve=RESOLVE_FULL); +private: + RegError eraseKey(ORegKey* pKey, const OUString& keyName); + + RegError deleteSubkeysAndValues(ORegKey* pKey); RegError loadAndSaveValue(ORegKey* pTargetKey, ORegKey* pSourceKey, @@ -189,17 +168,7 @@ protected: const OUString& sName, sal_Int16 nSpace) const; - RegError openKeyWithoutLink(RegKeyHandle hKey, - const OUString& keyName, - RegKeyHandle* phOpenKey); - - OUString resolveLinks(ORegKey* pKey, const OUString& path); - ORegKey* resolveLink(ORegKey* pKey, OUString& resolvedPath, const OUString& name); - - sal_Bool insertRecursionLink(ORegKey* pLink); - sal_Bool resetRecursionLinks(); - -protected: + typedef std::hash_map< OUString, ORegKey*, OUStringHash > KeyMap; sal_uInt32 m_refCount; Mutex m_mutex; @@ -208,7 +177,6 @@ protected: OUString m_name; OStoreFile m_file; KeyMap m_openKeyTable; - LinkList m_recursionList; const OUString ROOT; }; diff --git a/registry/source/regkey.cxx b/registry/source/regkey.cxx index 5c63c9cde09f..1d828a862a96 100644 --- a/registry/source/regkey.cxx +++ b/registry/source/regkey.cxx @@ -813,48 +813,17 @@ RegError REGISTRY_CALLTYPE freeValueList(RegValueType valueType, //********************************************************************* // createLink // -RegError REGISTRY_CALLTYPE createLink(RegKeyHandle hKey, - rtl_uString* linkName, - rtl_uString* linkTarget) +RegError REGISTRY_CALLTYPE createLink(RegKeyHandle, rtl_uString*, rtl_uString*) { - ORegKey* pKey; - - if (hKey) - { - pKey = (ORegKey*)hKey; - - if (pKey->isDeleted()) - return REG_INVALID_KEY; - } else - return REG_INVALID_KEY; - - if (pKey->isReadOnly()) - return REG_REGISTRY_READONLY; - - return pKey->createLink(linkName, linkTarget); + return REG_INVALID_LINK; // links are no longer supported } //********************************************************************* // deleteLink // -RegError REGISTRY_CALLTYPE deleteLink(RegKeyHandle hKey, - rtl_uString* linkName) +RegError REGISTRY_CALLTYPE deleteLink(RegKeyHandle, rtl_uString*) { - ORegKey* pKey; - - if (hKey) - { - pKey = (ORegKey*)hKey; - - if (pKey->isDeleted()) - return REG_INVALID_KEY; - } else - return REG_INVALID_KEY; - - if (pKey->isReadOnly()) - return REG_REGISTRY_READONLY; - - return pKey->deleteLink(linkName); + return REG_INVALID_LINK; // links are no longer supported } //********************************************************************* @@ -881,29 +850,12 @@ RegError REGISTRY_CALLTYPE getKeyType(RegKeyHandle hKey, //********************************************************************* // getLinkTarget // -RegError REGISTRY_CALLTYPE getLinkTarget(RegKeyHandle hKey, - rtl_uString* linkName, - rtl_uString** pLinkTarget) +RegError REGISTRY_CALLTYPE getLinkTarget( + RegKeyHandle, rtl_uString*, rtl_uString**) { - ORegKey* pKey; - - if (hKey) - { - pKey = (ORegKey*)hKey; - - if (pKey->isDeleted()) - return REG_INVALID_KEY; - } else - return REG_INVALID_KEY; - - OUString linkTarget; - RegError ret = pKey->getLinkTarget(linkName, linkTarget); - if (!ret) - rtl_uString_assign(pLinkTarget, linkTarget.pData); - return ret; + return REG_INVALID_LINK; // links are no longer supported } - //********************************************************************* // getName // diff --git a/registry/source/regmap.hxx b/registry/source/regmap.hxx deleted file mode 100644 index c16d99babcc0..000000000000 --- a/registry/source/regmap.hxx +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: regmap.hxx,v $ - * $Revision: 1.6 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _REGMAP_HXX_ -#define _REGMAP_HXX_ - -#include <hash_map> -#include <list> -#include <set> -#include <rtl/ustring.hxx> - -using namespace rtl; - -class ORegKey; - -struct EqualString -{ - sal_Bool operator()(const OUString& str1, const OUString& str2) const - { - return (str1 == str2); - } -}; - -struct HashString -{ - size_t operator()(const OUString& str) const - { - return str.hashCode(); - } -}; - -struct LessString -{ - sal_Bool operator()(const OUString& str1, const OUString& str2) const - { - return (str1 < str2); - } -}; - -typedef ::std::hash_map< OUString, ORegKey*, HashString, EqualString > KeyMap; - -typedef ::std::list< ORegKey* > LinkList; - -typedef ::std::set< OUString, LessString > StringSet; - -#endif diff --git a/registry/tools/checksingleton.cxx b/registry/tools/checksingleton.cxx index 9950087a8e7a..7900b1db7a62 100644 --- a/registry/tools/checksingleton.cxx +++ b/registry/tools/checksingleton.cxx @@ -33,7 +33,6 @@ #include <stdio.h> #include <string.h> -#include <set> #include "registry/registry.hxx" #include "registry/reflread.hxx" #include <rtl/ustring.hxx> @@ -105,8 +104,6 @@ struct LessString } }; -typedef ::std::set< OUString, LessString > StringSet; - class Options { public: diff --git a/registry/tools/regcompare.cxx b/registry/tools/regcompare.cxx index d7c9c03b5d8b..f41103afb826 100644 --- a/registry/tools/regcompare.cxx +++ b/registry/tools/regcompare.cxx @@ -112,7 +112,7 @@ struct LessString } }; -typedef ::std::set< OUString, LessString > StringSet; +typedef ::std::set< OUString > StringSet; class Options { @@ -1270,7 +1270,7 @@ static sal_uInt32 checkFieldsWithoutOrder(const OUString& keyName, } sal_Bool bFound = sal_False; - ::std::set< sal_uInt16, ::std::less< sal_uInt16 > > moreProps; + ::std::set< sal_uInt16 > moreProps; for (i=0; i < nFields1; i++) { @@ -1533,7 +1533,7 @@ static sal_uInt32 checkBlob(const OUString& keyName, typereg::Reader& reader1, s } sal_Bool bFound = sal_False; - ::std::set< sal_uInt16, ::std::less< sal_uInt16 > > moreReferences; + ::std::set< sal_uInt16 > moreReferences; for (i=0; i < nReference1; i++) { diff --git a/sal/osl/unx/module.c b/sal/osl/unx/module.c index 5da5ba803343..d486aad00e01 100644 --- a/sal/osl/unx/module.c +++ b/sal/osl/unx/module.c @@ -150,22 +150,16 @@ void SAL_CALL osl_unloadModule(oslModule hModule) if (hModule) { #ifndef NO_DL_FUNCTIONS -#ifndef GCC - /* gcc (2.9.1 (egcs), 295) registers atexit handlers for - * static destructors which obviously cannot - * be called after dlclose. A compiler "feature". The workaround for now - * is not to dlclose libraries. Since most of them are closed at shutdown - * this does not make that much a difference - */ int nRet = dlclose(hModule); #if OSL_DEBUG_LEVEL > 1 if (nRet != 0) { - fprintf(stderr, "Error osl_unlocadModule: %s\n", dlerror()); + fprintf(stderr, "Error osl_unloadModule: %s\n", dlerror()); } +#else + (void) nRet; #endif /* if OSL_DEBUG_LEVEL */ -#endif /* ifndef GCC */ #endif /* ifndef NO_DL_FUNCTIONS */ } diff --git a/sal/typesconfig/typesconfig.c b/sal/typesconfig/typesconfig.c index 1077df4e3b54..be02052378ae 100644 --- a/sal/typesconfig/typesconfig.c +++ b/sal/typesconfig/typesconfig.c @@ -28,13 +28,6 @@ * ************************************************************************/ -/* POSIX defines that a program is undefined after a SIG_SEGV. The - * code stopped working on Linux Kernel 2.6 so I have moved this back to - * use FORK. - * If at a later time the signals work correctly with the Linux Kernel 2.6 - * then this change may be reverted although not strictly posix safe. */ -#define USE_FORK_TO_CHECK 1 - #include <stdio.h> #include <stdlib.h> #include <errno.h> @@ -43,20 +36,10 @@ #include <unistd.h> #include <sys/types.h> -#define I_STDARG -#ifdef I_STDARG #include <stdarg.h> -#else -#include <varargs.h> -#endif -#define NO_USE_FORK_TO_CHECK -#ifdef USE_FORK_TO_CHECK -#include <sys/wait.h> -#else #include <signal.h> #include <setjmp.h> -#endif #define printTypeSize(Type,Name) printf( "sizeof(%s)\t\t= %d\n", Name, (int) sizeof (Type) ) @@ -99,22 +82,12 @@ typedef int (*TestFunc)( Type, void* ); |* Letzte Aenderung |* *************************************************************************/ -#ifdef I_STDARG void PrintArgs( int p, ... ) -#else -void PrintArgs( p, va_alist ) -int p; -va_dcl -#endif { int value; va_list ap; -#ifdef I_STDARG va_start( ap, p ); -#else - va_start( ap ); -#endif printf( "value = %d", p ); @@ -125,7 +98,6 @@ va_dcl va_end(ap); } -#ifndef USE_FORK_TO_CHECK /************************************************************************* |* |* SignalHdl() @@ -136,18 +108,16 @@ va_dcl |* Letzte Aenderung |* *************************************************************************/ -static jmp_buf check_env; -static int bSignal; + +static sigjmp_buf jmpbuf; +static volatile sig_atomic_t hit; + void SignalHdl( int sig ) { - bSignal = 1; - - fprintf( stderr, "Signal %d caught\n", sig ); - signal( SIGSEGV, SIG_DFL ); - signal( SIGBUS, SIG_DFL ); - siglongjmp( check_env, sig ); + (void) sig; // ignored + hit = 1; + siglongjmp(jmpbuf, 0); } -#endif /************************************************************************* |* @@ -161,40 +131,26 @@ void SignalHdl( int sig ) *************************************************************************/ int check( TestFunc func, Type eT, void* p ) { -#ifdef USE_FORK_TO_CHECK - pid_t nChild = fork(); - if ( nChild ) - { - int exitVal; - wait( &exitVal ); - if ( exitVal & 0xff ) - return -1; - else - return exitVal >> 8; - } - else - { - exit( func( eT, p ) ); - } -#else - int result; - - bSignal = 0; - - if ( !sigsetjmp( check_env, 1 ) ) - { - signal( SIGSEGV, SignalHdl ); - signal( SIGBUS, SignalHdl ); - result = func( eT, p ); - signal( SIGSEGV, SIG_DFL ); - signal( SIGBUS, SIG_DFL ); - } - - if ( bSignal ) - return -1; - else - return 0; -#endif + hit = 0; + if (sigsetjmp(jmpbuf, 1) == 0) { + struct sigaction sa; + sa.sa_handler = SignalHdl; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + if (sigaction(SIGBUS, &sa, NULL) != 0 || + sigaction(SIGSEGV, &sa, NULL) != 0) + { + abort(); + } + func(eT, p); + sa.sa_handler = SIG_DFL; + if (sigaction(SIGBUS, &sa, NULL) != 0 || + sigaction(SIGSEGV, &sa, NULL) != 0) + { + abort(); + } + } + return hit ? -1 : 0; } /************************************************************************* diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx index 73556dd5971c..e7c9ff1a5851 100644 --- a/stoc/source/javavm/javavm.cxx +++ b/stoc/source/javavm/javavm.cxx @@ -61,7 +61,6 @@ #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XCurrentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" -#include "com/sun/star/uri/ExternalUriReferenceTranslator.hpp" #include "com/sun/star/util/XMacroExpander.hpp" #include "com/sun/star/container/XNameAccess.hpp" #include "cppuhelper/exc_hlp.hxx" @@ -1642,18 +1641,6 @@ void JavaVirtualMachine::setUpUnoVirtualMachine(JNIEnv * environment) { "com::sun::star::lang::IllegalArgumentException")), static_cast< cppu::OWeakObject * >(this)); } - if (baseUrl.getLength() > 0) { - baseUrl = css::uri::ExternalUriReferenceTranslator::create(m_xContext)-> - translateToExternal(baseUrl); - if (baseUrl.getLength() == 0) { - throw css::uno::RuntimeException( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.uri.ExternalUriReferenceTranslator." - "translateToExternal failed")), - static_cast< cppu::OWeakObject * >(this)); - } - } rtl::OUString classPath; try { classPath = exp->expandMacros( |