Files
libreoffice/registry/source/keyimpl.cxx

1072 lines
28 KiB
C++
Raw Normal View History

2000-09-18 14:18:43 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 14:18:43 +00:00
*
* Copyright 2008 by Sun Microsystems, Inc.
2000-09-18 14:18:43 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 14:18:43 +00:00
*
* $RCSfile: keyimpl.cxx,v $
2008-10-01 08:05:58 +00:00
* $Revision: 1.9.10.1 $
2000-09-18 14:18:43 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 14:18:43 +00:00
*
* 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.
2000-09-18 14:18:43 +00:00
*
* 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).
2000-09-18 14:18:43 +00:00
*
* 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.
2000-09-18 14:18:43 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_registry.hxx"
2000-09-18 14:18:43 +00:00
#include "reflcnst.hxx"
#include "keyimpl.hxx"
#include <rtl/alloc.h>
#include <rtl/memory.h>
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
#include "rtl/ustrbuf.hxx"
namespace { static char const VALUE_PREFIX[] = "$VL_"; }
2000-09-18 14:18:43 +00:00
//*********************************************************************
// ORegKey()
//
ORegKey::ORegKey(const OUString& keyName, ORegistry* pReg)
2000-09-18 14:18:43 +00:00
: m_refCount(1)
, m_name(keyName)
, m_bDeleted(sal_False)
, m_pRegistry(pReg)
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
{}
2000-09-18 14:18:43 +00:00
//*********************************************************************
// createKey
//
RegError ORegKey::createKey(const OUString& keyName, RegKeyHandle* phNewKey)
{
return m_pRegistry->createKey(this, keyName, phNewKey);
}
//*********************************************************************
// openKey
//
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
RegError ORegKey::openKey(const OUString& keyName, RegKeyHandle* phOpenKey)
2000-09-18 14:18:43 +00:00
{
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
return (m_pRegistry->openKey(this, keyName, phOpenKey));
2000-09-18 14:18:43 +00:00
}
//*********************************************************************
// openSubKeys
//
RegError ORegKey::openSubKeys(const OUString& keyName, RegKeyHandle** phOpenSubKeys, sal_uInt32* pnSubKeys)
{
ORegKey* pKey;
OUString sFullKeyName, sSubKeyName;
RegKeyHandle hSKey = 0, hSubKey;
2000-09-18 14:18:43 +00:00
RegError _ret = REG_NO_ERROR;
sal_uInt32 nSubKeys;
ORegKey* *subKeys;
if ( keyName.getLength() )
{
_ret = openKey(keyName, &hSKey);
if (_ret)
2000-09-18 14:18:43 +00:00
{
*phOpenSubKeys = NULL;
*pnSubKeys = 0;
return _ret;
}
pKey = (ORegKey*)hSKey;
} else
{
pKey = this;
}
nSubKeys = pKey->countSubKeys();
*pnSubKeys = nSubKeys;
subKeys = (ORegKey**)rtl_allocateZeroMemory(nSubKeys * sizeof(ORegKey*));
OStoreDirectory::iterator iter;
OStoreDirectory rStoreDir(pKey->getStoreDir());
storeError _err = rStoreDir.first(iter);
nSubKeys = 0;
while ( _err == store_E_None )
{
if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR )
{
sSubKeyName = iter.m_pszName;
sFullKeyName = pKey->getName();
if (sFullKeyName.getLength() > 1)
sFullKeyName += m_pRegistry->ROOT;
sFullKeyName += sSubKeyName;
_ret = pKey->openKey(sSubKeyName, &hSubKey);
if (_ret)
2000-09-18 14:18:43 +00:00
{
*phOpenSubKeys = NULL;
*pnSubKeys = 0;
rtl_freeMemory(subKeys);
return _ret;
}
subKeys[nSubKeys] = ((ORegKey*)hSubKey);
nSubKeys++;
}
_err = rStoreDir.next(iter);
}
*phOpenSubKeys = (RegKeyHandle*)subKeys;
if (keyName.getLength())
{
closeKey(hSKey);
}
return REG_NO_ERROR;
}
//*********************************************************************
// getKeyNames
//
RegError ORegKey::getKeyNames(const OUString& keyName,
rtl_uString*** pSubKeyNames,
sal_uInt32* pnSubKeys)
{
ORegKey* pKey;
OUString sFullKeyName, sSubKeyName;
RegError _ret = REG_NO_ERROR;
sal_uInt32 nSubKeys;
rtl_uString** pSubKeys;
if (keyName.getLength())
{
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
_ret = openKey(keyName, (RegKeyHandle*)&pKey);
if (_ret)
2000-09-18 14:18:43 +00:00
{
*pSubKeyNames = NULL;
*pnSubKeys = 0;
return _ret;
}
} else
{
pKey = this;
}
nSubKeys = pKey->countSubKeys();
*pnSubKeys = nSubKeys;
pSubKeys = (rtl_uString**)rtl_allocateZeroMemory(nSubKeys * sizeof(rtl_uString*));
OStoreDirectory::iterator iter;
OStoreDirectory rStoreDir(pKey->getStoreDir());
storeError _err = rStoreDir.first(iter);
OUString subKey;
nSubKeys = 0;
while ( _err == store_E_None )
{
if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR)
{
sSubKeyName = iter.m_pszName;
sFullKeyName = pKey->getName();
if (sFullKeyName.getLength() > 1)
sFullKeyName += m_pRegistry->ROOT;
sFullKeyName += sSubKeyName;
subKey = sFullKeyName;
rtl_uString_newFromString(&pSubKeys[nSubKeys], subKey.pData);
nSubKeys++;
}
_err = rStoreDir.next(iter);
}
*pSubKeyNames = pSubKeys;
if (keyName.getLength())
{
closeKey((RegKeyHandle)pKey);
}
return REG_NO_ERROR;
}
//*********************************************************************
// closeKey
//
RegError ORegKey::closeKey(RegKeyHandle hKey)
{
return (m_pRegistry->closeKey(hKey));
}
//*********************************************************************
// deleteKey
//
RegError ORegKey::deleteKey(const OUString& keyName)
{
return (m_pRegistry->deleteKey(this, keyName));
}
//*********************************************************************
// getValueType
//
RegError ORegKey::getValueInfo(const OUString& valueName, RegValueType* pValueType, sal_uInt32* pValueSize) const
{
OStoreStream rValue;
sal_uInt8* pBuffer;
storeAccessMode accessMode = VALUE_MODE_OPEN;
if (m_pRegistry->isReadOnly())
{
accessMode = VALUE_MODE_OPENREAD;
}
OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) );
sImplValueName += valueName;
REG_GUARD(m_pRegistry->m_mutex);
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
if ( rValue.create(m_pRegistry->getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, accessMode) )
2000-09-18 14:18:43 +00:00
{
*pValueType = RG_VALUETYPE_NOT_DEFINED;
*pValueSize = 0;
return REG_VALUE_NOT_EXISTS;
}
pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE);
sal_uInt32 readBytes;
if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) )
{
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
if (readBytes != VALUE_HEADERSIZE)
{
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
sal_uInt32 size;
sal_uInt8 type = *((sal_uInt8*)pBuffer);
readUINT32(pBuffer+VALUE_TYPEOFFSET, size);
*pValueType = (RegValueType)type;
// if (*pValueType == RG_VALUETYPE_UNICODE)
// {
// *pValueSize = (size / 2) * sizeof(sal_Unicode);
// } else
// {
if (*pValueType > 4)
{
rtl_freeMemory(pBuffer);
pBuffer = (sal_uInt8*)rtl_allocateMemory(4);
rValue.readAt(VALUE_HEADEROFFSET, pBuffer, 4, readBytes);
readUINT32(pBuffer, size);
}
*pValueSize = size;
// }
rtl_freeMemory(pBuffer);
return REG_NO_ERROR;
}
//*********************************************************************
// setValue
//
RegError ORegKey::setValue(const OUString& valueName, RegValueType vType, RegValue value, sal_uInt32 vSize)
{
OStoreStream rValue;
sal_uInt8* pBuffer;
if (m_pRegistry->isReadOnly())
{
return REG_REGISTRY_READONLY;
}
if (vType > 4)
{
return REG_INVALID_VALUE;
}
OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) );
sImplValueName += valueName;
REG_GUARD(m_pRegistry->m_mutex);
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
if ( rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT , sImplValueName, VALUE_MODE_CREATE) )
2000-09-18 14:18:43 +00:00
{
return REG_SET_VALUE_FAILED;
}
sal_uInt32 size = vSize;
sal_uInt8 type = (sal_uInt8)vType;
pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE + size);
rtl_copyMemory(pBuffer, &type, 1);
writeUINT32(pBuffer+VALUE_TYPEOFFSET, size);
switch (vType)
{
case RG_VALUETYPE_NOT_DEFINED:
rtl_copyMemory(pBuffer+VALUE_HEADEROFFSET, value, size);
break;
case RG_VALUETYPE_LONG:
writeINT32(pBuffer+VALUE_HEADEROFFSET, *((sal_Int32*)value));
break;
case RG_VALUETYPE_STRING:
writeUtf8(pBuffer+VALUE_HEADEROFFSET, (const sal_Char*)value);
break;
case RG_VALUETYPE_UNICODE:
writeString(pBuffer+VALUE_HEADEROFFSET, (const sal_Unicode*)value);
break;
case RG_VALUETYPE_BINARY:
rtl_copyMemory(pBuffer+VALUE_HEADEROFFSET, value, size);
break;
default:
OSL_ASSERT(false);
break;
2000-09-18 14:18:43 +00:00
}
sal_uInt32 writenBytes;
if ( rValue.writeAt(0, pBuffer, VALUE_HEADERSIZE+size, writenBytes) )
{
rtl_freeMemory(pBuffer);
return REG_SET_VALUE_FAILED;
}
if (writenBytes != (VALUE_HEADERSIZE+size))
{
rtl_freeMemory(pBuffer);
return REG_SET_VALUE_FAILED;
}
rtl_freeMemory(pBuffer);
return REG_NO_ERROR;
}
//*********************************************************************
// setLongListValue
//
RegError ORegKey::setLongListValue(const OUString& valueName, sal_Int32* pValueList, sal_uInt32 len)
{
OStoreStream rValue;
sal_uInt8* pBuffer;
if (m_pRegistry->isReadOnly())
{
return REG_REGISTRY_READONLY;
}
OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) );
sImplValueName += valueName;
REG_GUARD(m_pRegistry->m_mutex);
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) )
2000-09-18 14:18:43 +00:00
{
return REG_SET_VALUE_FAILED;
}
sal_uInt32 size = 4; // 4 Bytes (sal_uInt32) fuer die Laenge
size += len * 4;
sal_uInt8 type = (sal_uInt8)RG_VALUETYPE_LONGLIST;
pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE + size);
rtl_copyMemory(pBuffer, &type, 1);
writeUINT32(pBuffer+VALUE_TYPEOFFSET, size);
writeUINT32(pBuffer+VALUE_HEADEROFFSET, len);
sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays
2001-01-10 09:15:54 +00:00
for (sal_uInt32 i=0; i < len; i++)
2000-09-18 14:18:43 +00:00
{
writeINT32(pBuffer+VALUE_HEADEROFFSET+offset, pValueList[i]);
offset += 4;
}
sal_uInt32 writenBytes;
if ( rValue.writeAt(0, pBuffer, VALUE_HEADERSIZE+size, writenBytes) )
{
rtl_freeMemory(pBuffer);
return REG_SET_VALUE_FAILED;
}
if (writenBytes != (VALUE_HEADEROFFSET+size))
{
rtl_freeMemory(pBuffer);
return REG_SET_VALUE_FAILED;
}
rtl_freeMemory(pBuffer);
return REG_NO_ERROR;
}
//*********************************************************************
// setStringListValue
//
RegError ORegKey::setStringListValue(const OUString& valueName, sal_Char** pValueList, sal_uInt32 len)
{
OStoreStream rValue;
sal_uInt8* pBuffer;
if (m_pRegistry->isReadOnly())
{
return REG_REGISTRY_READONLY;
}
OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) );
sImplValueName += valueName;
REG_GUARD(m_pRegistry->m_mutex);
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) )
2000-09-18 14:18:43 +00:00
{
return REG_SET_VALUE_FAILED;
}
sal_uInt32 size = 4; // 4 Bytes (sal_uInt32) fuer die Laenge
2001-01-10 09:15:54 +00:00
sal_uInt32 i;
2000-09-18 14:18:43 +00:00
for (i=0; i < len; i++)
{
size += 4 + strlen(pValueList[i]) + 1;
}
sal_uInt8 type = (sal_uInt8)RG_VALUETYPE_STRINGLIST;
pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE + size);
rtl_copyMemory(pBuffer, &type, 1);
writeUINT32(pBuffer+VALUE_TYPEOFFSET, size);
writeUINT32(pBuffer+VALUE_HEADEROFFSET, len);
sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays;
sal_uInt32 sLen = 0;
for (i=0; i < len; i++)
{
sLen = strlen(pValueList[i]) + 1;
writeUINT32(pBuffer+VALUE_HEADEROFFSET+offset, sLen);
offset += 4;
writeUtf8(pBuffer+VALUE_HEADEROFFSET+offset, pValueList[i]);
offset += sLen;
}
sal_uInt32 writenBytes;
if ( rValue.writeAt(0, pBuffer, VALUE_HEADERSIZE+size, writenBytes) )
{
rtl_freeMemory(pBuffer);
return REG_SET_VALUE_FAILED;
}
if (writenBytes != (VALUE_HEADERSIZE+size))
{
rtl_freeMemory(pBuffer);
return REG_SET_VALUE_FAILED;
}
rtl_freeMemory(pBuffer);
return REG_NO_ERROR;
}
//*********************************************************************
// setUnicodeListValue
//
RegError ORegKey::setUnicodeListValue(const OUString& valueName, sal_Unicode** pValueList, sal_uInt32 len)
{
OStoreStream rValue;
sal_uInt8* pBuffer;
if (m_pRegistry->isReadOnly())
{
return REG_REGISTRY_READONLY;
}
OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) );
sImplValueName += valueName;
REG_GUARD(m_pRegistry->m_mutex);
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) )
2000-09-18 14:18:43 +00:00
{
return REG_SET_VALUE_FAILED;
}
sal_uInt32 size = 4; // 4 Bytes (sal_uInt32) fuer die Laenge
2001-01-10 09:15:54 +00:00
sal_uInt32 i;
2000-09-18 14:18:43 +00:00
for (i=0; i < len; i++)
{
size += 4 + ((rtl_ustr_getLength(pValueList[i]) +1) * 2);
}
sal_uInt8 type = (sal_uInt8)RG_VALUETYPE_UNICODELIST;
pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE + size);
rtl_copyMemory(pBuffer, &type, 1);
writeUINT32(pBuffer+VALUE_TYPEOFFSET, size);
writeUINT32(pBuffer+VALUE_HEADEROFFSET, len);
sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays;
sal_uInt32 sLen = 0;
for (i=0; i < len; i++)
{
sLen = (rtl_ustr_getLength(pValueList[i]) + 1) * 2;
writeUINT32(pBuffer+VALUE_HEADEROFFSET+offset, sLen);
offset += 4;
writeString(pBuffer+VALUE_HEADEROFFSET+offset, pValueList[i]);
offset += sLen;
}
sal_uInt32 writenBytes;
if ( rValue.writeAt(0, pBuffer, VALUE_HEADERSIZE+size, writenBytes) )
{
rtl_freeMemory(pBuffer);
return REG_SET_VALUE_FAILED;
}
if (writenBytes != (VALUE_HEADERSIZE+size))
{
rtl_freeMemory(pBuffer);
return REG_SET_VALUE_FAILED;
}
rtl_freeMemory(pBuffer);
return REG_NO_ERROR;
}
//*********************************************************************
// getValue
//
RegError ORegKey::getValue(const OUString& valueName, RegValue value) const
{
OStoreStream rValue;
sal_uInt8* pBuffer;
RegValueType valueType;
sal_uInt32 valueSize;
storeAccessMode accessMode = VALUE_MODE_OPEN;
if (m_pRegistry->isReadOnly())
{
accessMode = VALUE_MODE_OPENREAD;
}
OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) );
sImplValueName += valueName;
REG_GUARD(m_pRegistry->m_mutex);
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, accessMode) )
2000-09-18 14:18:43 +00:00
{
return REG_VALUE_NOT_EXISTS;
}
pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE);
sal_uInt32 readBytes;
if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) )
{
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
if (readBytes != VALUE_HEADERSIZE)
{
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
sal_uInt8 type = *((sal_uInt8*)pBuffer);
valueType = (RegValueType)type;
readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize);
rtl_freeMemory(pBuffer);
if (valueType > 4)
{
return REG_INVALID_VALUE;
}
pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
if ( rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, readBytes) )
{
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
if (readBytes != valueSize)
{
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
// rtl_copyMemory(value, pBuffer, valueSize);
switch (valueType)
{
case RG_VALUETYPE_NOT_DEFINED:
rtl_copyMemory(value, pBuffer, valueSize);
break;
case RG_VALUETYPE_LONG:
readINT32(pBuffer, *((sal_Int32*)value));
break;
case RG_VALUETYPE_STRING:
readUtf8(pBuffer, (sal_Char*)value, valueSize);
break;
case RG_VALUETYPE_UNICODE:
readString(pBuffer, (sal_Unicode*)value, valueSize);
break;
case RG_VALUETYPE_BINARY:
rtl_copyMemory(value, pBuffer, valueSize);
break;
case RG_VALUETYPE_LONGLIST:
case RG_VALUETYPE_STRINGLIST:
case RG_VALUETYPE_UNICODELIST:
rtl_copyMemory(value, pBuffer, valueSize);
break;
}
rtl_freeMemory(pBuffer);
return REG_NO_ERROR;
}
//*********************************************************************
// getLongListValue
//
RegError ORegKey::getLongListValue(const OUString& valueName, sal_Int32** pValueList, sal_uInt32* pLen) const
{
OStoreStream rValue;
sal_uInt8* pBuffer;
RegValueType valueType;
sal_uInt32 valueSize;
storeAccessMode accessMode = VALUE_MODE_OPEN;
if (m_pRegistry->isReadOnly())
{
accessMode = VALUE_MODE_OPENREAD;
}
OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) );
sImplValueName += valueName;
REG_GUARD(m_pRegistry->m_mutex);
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, accessMode) )
2000-09-18 14:18:43 +00:00
{
pValueList = NULL;
*pLen = 0;
return REG_VALUE_NOT_EXISTS;
}
pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE);
sal_uInt32 readBytes;
if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) )
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
if (readBytes != VALUE_HEADERSIZE)
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
sal_uInt8 type = *((sal_uInt8*)pBuffer);
valueType = (RegValueType)type;
if (valueType != RG_VALUETYPE_LONGLIST)
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize);
rtl_freeMemory(pBuffer);
pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
if ( rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, readBytes) )
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
if (readBytes != valueSize)
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
sal_uInt32 len = 0;
readUINT32(pBuffer, len);
*pLen = len;
sal_Int32* pVList = (sal_Int32*)rtl_allocateZeroMemory(len * sizeof(sal_Int32));
sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays;
2001-01-10 09:15:54 +00:00
for (sal_uInt32 i=0; i < len; i++)
2000-09-18 14:18:43 +00:00
{
readINT32(pBuffer+offset, pVList[i]);
offset += 4;
}
*pValueList = pVList;
rtl_freeMemory(pBuffer);
return REG_NO_ERROR;
}
//*********************************************************************
// getStringListValue
//
RegError ORegKey::getStringListValue(const OUString& valueName, sal_Char*** pValueList, sal_uInt32* pLen) const
{
OStoreStream rValue;
sal_uInt8* pBuffer;
RegValueType valueType;
sal_uInt32 valueSize;
storeAccessMode accessMode = VALUE_MODE_OPEN;
if (m_pRegistry->isReadOnly())
{
accessMode = VALUE_MODE_OPENREAD;
}
OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) );
sImplValueName += valueName;
REG_GUARD(m_pRegistry->m_mutex);
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
if ( rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, accessMode) )
2000-09-18 14:18:43 +00:00
{
pValueList = NULL;
*pLen = 0;
return REG_VALUE_NOT_EXISTS;
}
pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE);
sal_uInt32 readBytes;
if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) )
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
if (readBytes != VALUE_HEADERSIZE)
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
sal_uInt8 type = *((sal_uInt8*)pBuffer);
valueType = (RegValueType)type;
if (valueType != RG_VALUETYPE_STRINGLIST)
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize);
rtl_freeMemory(pBuffer);
pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
if ( rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, readBytes) )
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
if (readBytes != valueSize)
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
sal_uInt32 len = 0;
readUINT32(pBuffer, len);
*pLen = len;
sal_Char** pVList = (sal_Char**)rtl_allocateZeroMemory(len * sizeof(sal_Char*));
sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays;
sal_uInt32 sLen = 0;
sal_Char *pValue;
2001-01-10 09:15:54 +00:00
for (sal_uInt32 i=0; i < len; i++)
2000-09-18 14:18:43 +00:00
{
readUINT32(pBuffer+offset, sLen);
offset += 4;
pValue = (sal_Char*)rtl_allocateMemory(sLen);
readUtf8(pBuffer+offset, pValue, sLen);
pVList[i] = pValue;
offset += sLen;
}
*pValueList = pVList;
rtl_freeMemory(pBuffer);
return REG_NO_ERROR;
}
//*********************************************************************
// getUnicodeListValue
//
RegError ORegKey::getUnicodeListValue(const OUString& valueName, sal_Unicode*** pValueList, sal_uInt32* pLen) const
{
OStoreStream rValue;
sal_uInt8* pBuffer;
RegValueType valueType;
sal_uInt32 valueSize;
storeAccessMode accessMode = VALUE_MODE_OPEN;
if (m_pRegistry->isReadOnly())
{
accessMode = VALUE_MODE_OPENREAD;
}
OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) );
sImplValueName += valueName;
REG_GUARD(m_pRegistry->m_mutex);
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
if ( rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, accessMode) )
2000-09-18 14:18:43 +00:00
{
pValueList = NULL;
*pLen = 0;
return REG_VALUE_NOT_EXISTS;
}
pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE);
sal_uInt32 readBytes;
if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) )
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
if (readBytes != VALUE_HEADERSIZE)
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
sal_uInt8 type = *((sal_uInt8*)pBuffer);
valueType = (RegValueType)type;
if (valueType != RG_VALUETYPE_UNICODELIST)
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize);
rtl_freeMemory(pBuffer);
pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
if ( rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, readBytes) )
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
if (readBytes != valueSize)
{
pValueList = NULL;
*pLen = 0;
rtl_freeMemory(pBuffer);
return REG_INVALID_VALUE;
}
sal_uInt32 len = 0;
readUINT32(pBuffer, len);
*pLen = len;
sal_Unicode** pVList = (sal_Unicode**)rtl_allocateZeroMemory(len * sizeof(sal_Unicode*));
sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays;
sal_uInt32 sLen = 0;
sal_Unicode *pValue;
2001-01-10 09:15:54 +00:00
for (sal_uInt32 i=0; i < len; i++)
2000-09-18 14:18:43 +00:00
{
readUINT32(pBuffer+offset, sLen);
offset += 4;
pValue = (sal_Unicode*)rtl_allocateMemory((sLen / 2) * sizeof(sal_Unicode));
readString(pBuffer+offset, pValue, sLen);
pVList[i] = pValue;
offset += sLen;
}
*pValueList = pVList;
rtl_freeMemory(pBuffer);
return REG_NO_ERROR;
}
//*********************************************************************
// getKeyType()
//
RegError ORegKey::getKeyType(const OUString& name, RegKeyType* pKeyType) const
{
ORegKey* pKey;
RegError _ret = REG_NO_ERROR;
*pKeyType = RG_KEYTYPE;
REG_GUARD(m_pRegistry->m_mutex);
if ( name.getLength() )
{
_ret = ((ORegKey*)this)->openKey(
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
name, (RegKeyHandle*)&pKey);
if (_ret)
2000-09-18 14:18:43 +00:00
return _ret;
((ORegKey*)this)->closeKey((RegKeyHandle)pKey);
return _ret;
} else
{
return _ret;
}
}
RegError ORegKey::getResolvedKeyName(const OUString& keyName,
OUString& resolvedName)
2000-09-18 14:18:43 +00:00
{
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
if (keyName.getLength() == 0) {
return REG_INVALID_KEYNAME;
}
resolvedName = getFullPath(keyName);
return REG_NO_ERROR;
2000-09-18 14:18:43 +00:00
}
//*********************************************************************
// countSubKeys()
//
sal_uInt32 ORegKey::countSubKeys()
{
REG_GUARD(m_pRegistry->m_mutex);
OStoreDirectory::iterator iter;
OStoreDirectory rStoreDir = getStoreDir();
storeError _err = rStoreDir.first(iter);
sal_uInt32 count = 0;
while ( _err == store_E_None )
{
if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR )
{
count++;
}
_err = rStoreDir.next(iter);
}
return count;
}
OStoreDirectory ORegKey::getStoreDir()
{
OStoreDirectory rStoreDir;
OUString fullPath;
OUString relativName;
storeAccessMode accessMode = KEY_MODE_OPEN;
if ( m_name.equals(m_pRegistry->ROOT) )
{
fullPath = OUString();
relativName = OUString();
} else
{
fullPath = m_name.copy(0, m_name.lastIndexOf('/') + 1);
relativName = m_name.copy(m_name.lastIndexOf('/') + 1);
}
if (m_pRegistry->isReadOnly())
{
accessMode = KEY_MODE_OPENREAD;
}
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
rStoreDir.create(getStoreFile(), fullPath, relativName, accessMode);
2000-09-18 14:18:43 +00:00
return rStoreDir;
}
CWS-TOOLING: integrate CWS sb103 2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment) 2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required 2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38) 2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup 2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc) 2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables 2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway 2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree 2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc) 2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora) 2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so 2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called 2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
2009-02-12 09:18:09 +00:00
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();
}