28#include <rtl/ustrbuf.hxx>
29#include <osl/diagnose.h>
35namespace {
char const VALUE_PREFIX[] =
"$VL_"; }
70 *phOpenSubKeys =
nullptr;
74 if ( !keyName.empty() )
82 *pnSubKeys = nSubKeys;
85 pSubKeys =
static_cast<ORegKey**
>(rtl_allocateZeroMemory(nSubKeys *
sizeof(
ORegKey*)));
102 *phOpenSubKeys =
nullptr;
108 pSubKeys[nSubKeys] = pOpenSubKey;
113 _err = rStoreDir.
next(iter);
116 *phOpenSubKeys =
reinterpret_cast<RegKeyHandle*
>(pSubKeys);
117 if (!keyName.empty())
125 rtl_uString*** pSubKeyNames,
126 sal_uInt32* pnSubKeys)
128 *pSubKeyNames =
nullptr;
132 if (!keyName.empty())
140 *pnSubKeys = nSubKeys;
142 rtl_uString** pSubKeys
143 =
static_cast<rtl_uString**
>(rtl_allocateZeroMemory(nSubKeys *
sizeof(rtl_uString*)));
157 OUString sFullKeyName(pKey->
getName());
158 if (sFullKeyName.getLength() > 1)
160 sFullKeyName += sSubKeyName;
162 rtl_uString_newFromString(&pSubKeys[nSubKeys], sFullKeyName.pData);
167 _err = rStoreDir.
next(iter);
170 *pSubKeyNames = pSubKeys;
171 if (!keyName.empty())
191 std::unique_ptr<sal_uInt8[]> pBuffer;
196 accessMode = storeAccessMode::ReadOnly;
199 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
212 sal_uInt32 readBytes;
243 std::unique_ptr<sal_uInt8[]> pBuffer;
255 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
264 sal_uInt32
size = vSize;
268 memcpy(pBuffer.get(), &
type, 1);
294 sal_uInt32 writenBytes;
311 std::unique_ptr<sal_uInt8[]> pBuffer;
318 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
333 memcpy(pBuffer.get(), &
type, 1);
338 sal_uInt32 offset = 4;
340 for (sal_uInt32
i=0;
i < len;
i++)
346 sal_uInt32 writenBytes;
361 std::u16string_view valueName,
char** pValueList, sal_uInt32 len)
364 std::unique_ptr<sal_uInt8[]> pBuffer;
371 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
383 for (
i=0;
i < len;
i++)
385 size += 4 + strlen(pValueList[
i]) + 1;
390 memcpy(pBuffer.get(), &
type, 1);
395 sal_uInt32 offset = 4;
398 for (
i=0;
i < len;
i++)
400 sLen = strlen(pValueList[
i]) + 1;
408 sal_uInt32 writenBytes;
425 std::unique_ptr<sal_uInt8[]> pBuffer;
432 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
444 for (
i=0;
i < len;
i++)
446 size += 4 + ((rtl_ustr_getLength(pValueList[
i]) +1) * 2);
451 memcpy(pBuffer.get(), &
type, 1);
456 sal_uInt32 offset = 4;
459 for (
i=0;
i < len;
i++)
461 sLen = (rtl_ustr_getLength(pValueList[
i]) + 1) * 2;
469 sal_uInt32 writenBytes;
486 std::unique_ptr<sal_uInt8[]> pBuffer;
488 sal_uInt32 valueSize;
493 accessMode = storeAccessMode::ReadOnly;
496 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
507 sal_uInt32 readBytes;
532 if (readBytes != valueSize)
543 readUtf8(pBuffer.get(),
static_cast<char*
>(
value), valueSize);
549 memcpy(
value, pBuffer.get(), valueSize);
552 memcpy(
value, pBuffer.get(), valueSize);
562 std::unique_ptr<sal_uInt8[]> pBuffer;
564 sal_uInt32 valueSize;
569 accessMode = storeAccessMode::ReadOnly;
572 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
578 pValueList =
nullptr;
585 sal_uInt32 readBytes;
588 pValueList =
nullptr;
594 pValueList =
nullptr;
604 pValueList =
nullptr;
613 if(valueSize > 40000000)
615 pValueList =
nullptr;
623 pValueList =
nullptr;
627 if (readBytes != valueSize)
629 pValueList =
nullptr;
638 if(len > (valueSize - 4) / 4)
640 pValueList =
nullptr;
645 sal_Int32* pVList =
static_cast<sal_Int32*
>(rtl_allocateZeroMemory(len *
sizeof(sal_Int32)));
647 sal_uInt32 offset = 4;
649 for (sal_uInt32
i = 0;
i < len;
i++)
655 *pValueList = pVList;
662 std::unique_ptr<sal_uInt8[]> pBuffer;
664 sal_uInt32 valueSize;
669 accessMode = storeAccessMode::ReadOnly;
672 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
678 pValueList =
nullptr;
685 sal_uInt32 readBytes;
688 pValueList =
nullptr;
694 pValueList =
nullptr;
704 pValueList =
nullptr;
715 pValueList =
nullptr;
719 if (readBytes != valueSize)
721 pValueList =
nullptr;
730 char** pVList =
static_cast<char**
>(rtl_allocateZeroMemory(len *
sizeof(
char*)));
732 sal_uInt32 offset = 4;
736 for (sal_uInt32
i=0;
i < len;
i++)
742 pValue =
static_cast<char*
>(std::malloc(sLen));
743 readUtf8(pBuffer.get()+offset, pValue, sLen);
749 *pValueList = pVList;
756 std::unique_ptr<sal_uInt8[]> pBuffer;
758 sal_uInt32 valueSize;
763 accessMode = storeAccessMode::ReadOnly;
766 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
772 pValueList =
nullptr;
779 sal_uInt32 readBytes;
782 pValueList =
nullptr;
788 pValueList =
nullptr;
796 if (valueType != RegValueType::UNICODELIST)
798 pValueList =
nullptr;
809 pValueList =
nullptr;
813 if (readBytes != valueSize)
815 pValueList =
nullptr;
826 sal_uInt32 offset = 4;
830 for (sal_uInt32
i=0;
i < len;
i++)
837 readString(pBuffer.get()+offset, pValue, sLen);
843 *pValueList = pVList;
849 OUString& resolvedName)
const
865 sal_uInt32
count = 0;
874 _err = rStoreDir.
next(iter);
884 OUString relativName;
899 accessMode = storeAccessMode::ReadOnly;
908 OSL_ASSERT(!
m_name.isEmpty() && !path.empty());
909 OUStringBuffer b(32);
911 if (!b.isEmpty() && b[b.getLength() - 1] ==
'/') {
912 if (path[0] ==
'/') {
913 b.append(path.substr(1));
918 if (path[0] !=
'/') {
923 return b.makeStringAndClear();
RegError createKey(std::u16string_view keyName, RegKeyHandle *phNewKey)
RegError setUnicodeListValue(std::u16string_view valueName, sal_Unicode **pValueList, sal_uInt32 len)
RegError getValueInfo(std::u16string_view valueName, RegValueType *pValueTye, sal_uInt32 *pValueSize) const
RegError getValue(std::u16string_view valueName, RegValue value) const
void setModified(bool bModified=true)
RegError setLongListValue(std::u16string_view valueName, sal_Int32 const *pValueList, sal_uInt32 len)
OUString getFullPath(std::u16string_view path) const
RegError releaseKey(RegKeyHandle hKey)
RegError getResolvedKeyName(std::u16string_view keyName, OUString &resolvedName) const
sal_uInt32 countSubKeys()
RegError getStringListValue(std::u16string_view valueName, char ***pValueList, sal_uInt32 *pLen) const
RegError getKeyNames(std::u16string_view keyName, rtl_uString ***pSubKeyNames, sal_uInt32 *pnSubKeys)
RegError getLongListValue(std::u16string_view valueName, sal_Int32 **pValueList, sal_uInt32 *pLen) const
RegError getUnicodeListValue(std::u16string_view valueName, sal_Unicode ***pValueList, sal_uInt32 *pLen) const
const store::OStoreFile & getStoreFile() const
RegError setValue(std::u16string_view valueName, RegValueType vType, RegValue value, sal_uInt32 vSize)
RegError openKey(std::u16string_view keyName, RegKeyHandle *phOpenKey)
RegError deleteKey(std::u16string_view keyName)
RegError openSubKeys(std::u16string_view keyName, RegKeyHandle **phOpenSubKeys, sal_uInt32 *pnSubKeys)
RegError setStringListValue(std::u16string_view valueName, char **pValueList, sal_uInt32 len)
RegError closeKey(RegKeyHandle hKey)
ORegKey(const OUString &keyName, ORegistry *pReg)
const OUString & getName() const
store::OStoreDirectory getStoreDir() const
const store::OStoreFile & getStoreFile() const
RegError closeKey(RegKeyHandle hKey)
RegError openKey(RegKeyHandle hKey, std::u16string_view keyName, RegKeyHandle *phOpenKey)
RegError deleteKey(RegKeyHandle hKey, std::u16string_view keyName)
static constexpr OUStringLiteral ROOT
RegError createKey(RegKeyHandle hKey, std::u16string_view keyName, RegKeyHandle *phNewKey)
RegError releaseKey(RegKeyHandle hKey)
storeError next(iterator &it)
storeError create(storeFileHandle hFile, OUString const &rPath, OUString const &rName, storeAccessMode eMode)
storeError first(iterator &it)
storeError writeAt(sal_uInt32 nOffset, void const *pBuffer, sal_uInt32 nBytes, sal_uInt32 &rnDone)
storeError readAt(sal_uInt32 nOffset, void *pBuffer, sal_uInt32 nBytes, sal_uInt32 &rnDone)
storeError create(storeFileHandle hFile, OUString const &rPath, OUString const &rName, storeAccessMode eMode)
#define SAL_WARN_IF(condition, area, stream)
sal_uInt32 writeString(sal_uInt8 *buffer, const sal_Unicode *v)
sal_uInt32 writeUINT32(sal_uInt8 *buffer, sal_uInt32 v)
sal_uInt32 readString(const sal_uInt8 *buffer, sal_Unicode *v, sal_uInt32 maxSize)
sal_uInt32 readINT32(const sal_uInt8 *buffer, sal_Int32 &v)
sal_uInt32 readUINT32(const sal_uInt8 *buffer, sal_uInt32 &v)
sal_uInt32 writeINT32(sal_uInt8 *buffer, sal_Int32 v)
sal_uInt32 readUtf8(const sal_uInt8 *buffer, char *v, sal_uInt32 maxSize)
sal_uInt32 writeUtf8(sal_uInt8 *buffer, const char *v)
#define VALUE_HEADEROFFSET
STRINGLIST
The key has a value of type ascii string list.
INVALID_VALUE
the key has an invalid value or the value type is unknown.
VALUE_NOT_EXISTS
the key has no value
void * RegKeyHandle
defines the type of a registry key handle used in the C API.
UNICODE
The key has a value of type unicode string.
REGISTRY_READONLY
registry is open with readonly access rights.
NOT_DEFINED
The key has no value or the value type is unknown.
SET_VALUE_FAILED
setting the specified value of a key failed.
INVALID_KEYNAME
the keyname is invalid.
enum SAL_DLLPUBLIC_RTTI RegValueType
defines the type of a key value.
void * RegValue
defines the type of a registry key value handle used in the C API.
LONGLIST
The key has a value of type long list.
BINARY
The key has a value of type binary.
LONG
The key has a value of type long.
STRING
The key has a value of type ascii string.
enum SAL_DLLPUBLIC_RTTI RegError
specifies the possible error codes which can occur using the registry API.
sal_Unicode m_pszName[STORE_MAXIMUM_NAMESIZE]
constexpr sal_uInt32 STORE_ATTRIB_ISDIR