28#include <rtl/ustrbuf.hxx>
29#include <osl/diagnose.h>
36namespace {
char const VALUE_PREFIX[] =
"$VL_"; }
71 *phOpenSubKeys =
nullptr;
75 if ( !keyName.empty() )
83 *pnSubKeys = nSubKeys;
86 pSubKeys =
static_cast<ORegKey**
>(rtl_allocateZeroMemory(nSubKeys *
sizeof(
ORegKey*)));
103 *phOpenSubKeys =
nullptr;
109 pSubKeys[nSubKeys] = pOpenSubKey;
114 _err = rStoreDir.
next(iter);
117 *phOpenSubKeys =
reinterpret_cast<RegKeyHandle*
>(pSubKeys);
118 if (!keyName.empty())
126 rtl_uString*** pSubKeyNames,
127 sal_uInt32* pnSubKeys)
129 *pSubKeyNames =
nullptr;
133 if (!keyName.empty())
141 *pnSubKeys = nSubKeys;
143 rtl_uString** pSubKeys
144 =
static_cast<rtl_uString**
>(rtl_allocateZeroMemory(nSubKeys *
sizeof(rtl_uString*)));
158 OUString sFullKeyName(pKey->
getName());
159 if (sFullKeyName.getLength() > 1)
161 sFullKeyName += sSubKeyName;
163 rtl_uString_newFromString(&pSubKeys[nSubKeys], sFullKeyName.pData);
168 _err = rStoreDir.
next(iter);
171 *pSubKeyNames = pSubKeys;
172 if (!keyName.empty())
192 std::unique_ptr<sal_uInt8[]> pBuffer;
197 accessMode = storeAccessMode::ReadOnly;
200 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
213 sal_uInt32 readBytes;
216 return RegError::INVALID_VALUE;
220 return RegError::INVALID_VALUE;
244 std::unique_ptr<sal_uInt8[]> pBuffer;
253 return RegError::INVALID_VALUE;
256 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
265 sal_uInt32
size = vSize;
269 memcpy(pBuffer.get(), &
type, 1);
295 sal_uInt32 writenBytes;
312 std::unique_ptr<sal_uInt8[]> pBuffer;
319 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
334 memcpy(pBuffer.get(), &
type, 1);
339 sal_uInt32 offset = 4;
341 for (sal_uInt32
i=0;
i < len;
i++)
347 sal_uInt32 writenBytes;
362 std::u16string_view valueName,
char** pValueList, sal_uInt32 len)
365 std::unique_ptr<sal_uInt8[]> pBuffer;
372 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
384 for (
i=0;
i < len;
i++)
386 size += 4 + strlen(pValueList[
i]) + 1;
391 memcpy(pBuffer.get(), &
type, 1);
396 sal_uInt32 offset = 4;
399 for (
i=0;
i < len;
i++)
401 sLen = strlen(pValueList[
i]) + 1;
409 sal_uInt32 writenBytes;
426 std::unique_ptr<sal_uInt8[]> pBuffer;
433 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
445 for (
i=0;
i < len;
i++)
447 size += 4 + ((rtl_ustr_getLength(pValueList[
i]) +1) * 2);
452 memcpy(pBuffer.get(), &
type, 1);
457 sal_uInt32 offset = 4;
460 for (
i=0;
i < len;
i++)
462 sLen = (rtl_ustr_getLength(pValueList[
i]) + 1) * 2;
470 sal_uInt32 writenBytes;
487 std::unique_ptr<sal_uInt8[]> pBuffer;
489 sal_uInt32 valueSize;
494 accessMode = storeAccessMode::ReadOnly;
497 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
508 sal_uInt32 readBytes;
511 return RegError::INVALID_VALUE;
515 return RegError::INVALID_VALUE;
524 return RegError::INVALID_VALUE;
531 return RegError::INVALID_VALUE;
533 if (readBytes != valueSize)
535 return RegError::INVALID_VALUE;
544 readUtf8(pBuffer.get(),
static_cast<char*
>(
value), valueSize);
550 memcpy(
value, pBuffer.get(), valueSize);
553 memcpy(
value, pBuffer.get(), valueSize);
563 std::unique_ptr<sal_uInt8[]> pBuffer;
565 sal_uInt32 valueSize;
570 accessMode = storeAccessMode::ReadOnly;
573 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
579 pValueList =
nullptr;
586 sal_uInt32 readBytes;
589 pValueList =
nullptr;
591 return RegError::INVALID_VALUE;
595 pValueList =
nullptr;
597 return RegError::INVALID_VALUE;
605 pValueList =
nullptr;
607 return RegError::INVALID_VALUE;
614 if(valueSize > 40000000)
616 pValueList =
nullptr;
618 return RegError::INVALID_VALUE;
624 pValueList =
nullptr;
626 return RegError::INVALID_VALUE;
628 if (readBytes != valueSize)
630 pValueList =
nullptr;
632 return RegError::INVALID_VALUE;
639 if(len > (valueSize - 4) / 4)
641 pValueList =
nullptr;
643 return RegError::INVALID_VALUE;
646 sal_Int32* pVList =
static_cast<sal_Int32*
>(rtl_allocateZeroMemory(len *
sizeof(sal_Int32)));
648 sal_uInt32 offset = 4;
650 for (sal_uInt32
i = 0;
i < len;
i++)
656 *pValueList = pVList;
663 std::unique_ptr<sal_uInt8[]> pBuffer;
665 sal_uInt32 valueSize;
670 accessMode = storeAccessMode::ReadOnly;
673 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
679 pValueList =
nullptr;
686 sal_uInt32 readBytes;
689 pValueList =
nullptr;
691 return RegError::INVALID_VALUE;
695 pValueList =
nullptr;
697 return RegError::INVALID_VALUE;
705 pValueList =
nullptr;
707 return RegError::INVALID_VALUE;
716 pValueList =
nullptr;
718 return RegError::INVALID_VALUE;
720 if (readBytes != valueSize)
722 pValueList =
nullptr;
724 return RegError::INVALID_VALUE;
731 char** pVList =
static_cast<char**
>(rtl_allocateZeroMemory(len *
sizeof(
char*)));
733 sal_uInt32 offset = 4;
737 for (sal_uInt32
i=0;
i < len;
i++)
743 pValue =
static_cast<char*
>(std::malloc(sLen));
744 readUtf8(pBuffer.get()+offset, pValue, sLen);
750 *pValueList = pVList;
757 std::unique_ptr<sal_uInt8[]> pBuffer;
759 sal_uInt32 valueSize;
764 accessMode = storeAccessMode::ReadOnly;
767 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
773 pValueList =
nullptr;
780 sal_uInt32 readBytes;
783 pValueList =
nullptr;
785 return RegError::INVALID_VALUE;
789 pValueList =
nullptr;
791 return RegError::INVALID_VALUE;
797 if (valueType != RegValueType::UNICODELIST)
799 pValueList =
nullptr;
801 return RegError::INVALID_VALUE;
810 pValueList =
nullptr;
812 return RegError::INVALID_VALUE;
814 if (readBytes != valueSize)
816 pValueList =
nullptr;
818 return RegError::INVALID_VALUE;
827 sal_uInt32 offset = 4;
831 for (sal_uInt32
i=0;
i < len;
i++)
838 readString(pBuffer.get()+offset, pValue, sLen);
844 *pValueList = pVList;
850 OUString& resolvedName)
const
866 sal_uInt32
count = 0;
875 _err = rStoreDir.
next(iter);
885 OUString relativName;
900 accessMode = storeAccessMode::ReadOnly;
909 OSL_ASSERT(!
m_name.isEmpty() && !path.empty());
910 OUStringBuffer b(32);
912 if (!b.isEmpty() && b[b.getLength() - 1] ==
'/') {
913 if (path[0] ==
'/') {
914 b.append(path.substr(1));
919 if (path[0] !=
'/') {
924 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
ORegKey(OUString keyName, ORegistry *pReg)
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)
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.
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