22 #include <string_view>
27 #include <rtl/alloc.h>
28 #include <rtl/ustrbuf.hxx>
29 #include <osl/diagnose.h>
33 using namespace store;
35 namespace {
char const VALUE_PREFIX[] =
"$VL_"; }
88 *phOpenSubKeys =
nullptr;
92 if ( !keyName.isEmpty() )
94 _ret =
openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pKey));
100 *pnSubKeys = nSubKeys;
103 pSubKeys =
static_cast<ORegKey**
>(rtl_allocateZeroMemory(nSubKeys *
sizeof(
ORegKey*)));
116 ORegKey* pOpenSubKey =
nullptr;
117 _ret = pKey->
openKey(sSubKeyName, reinterpret_cast<RegKeyHandle*>(&pOpenSubKey));
120 *phOpenSubKeys =
nullptr;
126 pSubKeys[nSubKeys] = pOpenSubKey;
131 _err = rStoreDir.next(iter);
134 *phOpenSubKeys =
reinterpret_cast<RegKeyHandle*
>(pSubKeys);
135 if (!keyName.isEmpty())
146 rtl_uString*** pSubKeyNames,
147 sal_uInt32* pnSubKeys)
149 *pSubKeyNames =
nullptr;
153 if (!keyName.isEmpty())
155 RegError _ret =
openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pKey));
161 *pnSubKeys = nSubKeys;
163 rtl_uString** pSubKeys
164 =
static_cast<rtl_uString**
>(rtl_allocateZeroMemory(nSubKeys *
sizeof(rtl_uString*)));
178 OUString sFullKeyName(pKey->
getName());
179 if (sFullKeyName.getLength() > 1)
180 sFullKeyName += ORegistry::ROOT;
181 sFullKeyName += sSubKeyName;
183 rtl_uString_newFromString(&pSubKeys[nSubKeys], sFullKeyName.pData);
188 _err = rStoreDir.next(iter);
191 *pSubKeyNames = pSubKeys;
192 if (!keyName.isEmpty())
221 std::unique_ptr<sal_uInt8[]> pBuffer;
226 accessMode = storeAccessMode::ReadOnly;
229 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
242 sal_uInt32 readBytes;
247 if (readBytes != VALUE_HEADERSIZE)
276 std::unique_ptr<sal_uInt8[]> pBuffer;
288 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
297 sal_uInt32
size = vSize;
301 memcpy(pBuffer.get(), &type, 1);
327 sal_uInt32 writenBytes;
347 std::unique_ptr<sal_uInt8[]> pBuffer;
354 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
369 memcpy(pBuffer.get(), &type, 1);
374 sal_uInt32 offset = 4;
376 for (sal_uInt32
i=0;
i < len;
i++)
382 sal_uInt32 writenBytes;
400 std::u16string_view valueName,
char** pValueList, sal_uInt32 len)
403 std::unique_ptr<sal_uInt8[]> pBuffer;
410 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
422 for (i=0; i < len; i++)
424 size += 4 + strlen(pValueList[i]) + 1;
429 memcpy(pBuffer.get(), &type, 1);
434 sal_uInt32 offset = 4;
437 for (i=0; i < len; i++)
439 sLen = strlen(pValueList[i]) + 1;
447 sal_uInt32 writenBytes;
467 std::unique_ptr<sal_uInt8[]> pBuffer;
474 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
486 for (i=0; i < len; i++)
488 size += 4 + ((rtl_ustr_getLength(pValueList[i]) +1) * 2);
493 memcpy(pBuffer.get(), &type, 1);
498 sal_uInt32 offset = 4;
501 for (i=0; i < len; i++)
503 sLen = (rtl_ustr_getLength(pValueList[i]) + 1) * 2;
511 sal_uInt32 writenBytes;
531 std::unique_ptr<sal_uInt8[]> pBuffer;
533 sal_uInt32 valueSize;
538 accessMode = storeAccessMode::ReadOnly;
541 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
552 sal_uInt32 readBytes;
557 if (readBytes != VALUE_HEADERSIZE)
577 if (readBytes != valueSize)
585 memcpy(value, pBuffer.get(), valueSize);
588 readINT32(pBuffer.get(), *
static_cast<sal_Int32*
>(value));
591 readUtf8(pBuffer.get(),
static_cast<char*
>(value), valueSize);
597 memcpy(value, pBuffer.get(), valueSize);
602 case RegValueType::UNICODELIST:
603 memcpy(value, pBuffer.get(), valueSize);
616 std::unique_ptr<sal_uInt8[]> pBuffer;
618 sal_uInt32 valueSize;
623 accessMode = storeAccessMode::ReadOnly;
626 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
632 pValueList =
nullptr;
639 sal_uInt32 readBytes;
642 pValueList =
nullptr;
646 if (readBytes != VALUE_HEADERSIZE)
648 pValueList =
nullptr;
658 pValueList =
nullptr;
667 if(valueSize > 40000000)
669 pValueList =
nullptr;
677 pValueList =
nullptr;
681 if (readBytes != valueSize)
683 pValueList =
nullptr;
692 if(len > (valueSize - 4) / 4)
694 pValueList =
nullptr;
699 sal_Int32* pVList =
static_cast<sal_Int32*
>(rtl_allocateZeroMemory(len *
sizeof(sal_Int32)));
701 sal_uInt32 offset = 4;
703 for (sal_uInt32
i = 0;
i < len;
i++)
709 *pValueList = pVList;
719 std::unique_ptr<sal_uInt8[]> pBuffer;
721 sal_uInt32 valueSize;
726 accessMode = storeAccessMode::ReadOnly;
729 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
735 pValueList =
nullptr;
742 sal_uInt32 readBytes;
745 pValueList =
nullptr;
749 if (readBytes != VALUE_HEADERSIZE)
751 pValueList =
nullptr;
761 pValueList =
nullptr;
772 pValueList =
nullptr;
776 if (readBytes != valueSize)
778 pValueList =
nullptr;
787 char** pVList =
static_cast<char**
>(rtl_allocateZeroMemory(len *
sizeof(
char*)));
789 sal_uInt32 offset = 4;
793 for (sal_uInt32
i=0;
i < len;
i++)
799 pValue =
static_cast<char*
>(std::malloc(sLen));
800 readUtf8(pBuffer.get()+offset, pValue, sLen);
806 *pValueList = pVList;
816 std::unique_ptr<sal_uInt8[]> pBuffer;
818 sal_uInt32 valueSize;
823 accessMode = storeAccessMode::ReadOnly;
826 OUString sImplValueName = OUString::Concat(VALUE_PREFIX) + valueName;
832 pValueList =
nullptr;
839 sal_uInt32 readBytes;
842 pValueList =
nullptr;
846 if (readBytes != VALUE_HEADERSIZE)
848 pValueList =
nullptr;
856 if (valueType != RegValueType::UNICODELIST)
858 pValueList =
nullptr;
869 pValueList =
nullptr;
873 if (readBytes != valueSize)
875 pValueList =
nullptr;
886 sal_uInt32 offset = 4;
890 for (sal_uInt32
i=0;
i < len;
i++)
897 readString(pBuffer.get()+offset, pValue, sLen);
903 *pValueList = pVList;
909 OUString& resolvedName)
const
911 if (keyName.isEmpty())
928 sal_uInt32
count = 0;
937 _err = rStoreDir.
next(iter);
947 OUString relativName;
950 if (
m_name == ORegistry::ROOT )
962 accessMode = storeAccessMode::ReadOnly;
971 OSL_ASSERT(!
m_name.isEmpty() && !path.isEmpty());
972 OUStringBuffer b(32);
974 if (!b.isEmpty() && b[b.getLength() - 1] ==
'/') {
975 if (path[0] ==
'/') {
976 b.append(std::u16string_view(path).substr(1));
981 if (path[0] !=
'/') {
986 return b.makeStringAndClear();
const OUString & getName() const
STRINGLIST
The key has a value of type ascii string list.
STRING
The key has a value of type ascii string.
const size_t count(pCandidateA->getBorderLines().size())
#define VALUE_HEADEROFFSET
ORegKey(const OUString &keyName, ORegistry *pReg)
constexpr sal_uInt32 STORE_ATTRIB_ISDIR
RegError openSubKeys(const OUString &keyName, RegKeyHandle **phOpenSubKeys, sal_uInt32 *pnSubKeys)
UNICODE
The key has a value of type unicode string.
storeError create(storeFileHandle hFile, OUString const &rPath, OUString const &rName, storeAccessMode eMode)
RegError getResolvedKeyName(const OUString &keyName, OUString &resolvedName) const
LONG
The key has a value of type long.
RegError deleteKey(const OUString &keyName)
LONGLIST
The key has a value of type long list.
RegError deleteKey(RegKeyHandle hKey, const OUString &keyName)
RegError releaseKey(RegKeyHandle hKey)
RegError setUnicodeListValue(std::u16string_view valueName, sal_Unicode **pValueList, sal_uInt32 len)
RegError createKey(RegKeyHandle hKey, const OUString &keyName, RegKeyHandle *phNewKey)
NOT_DEFINED
The key has no value or the value type is unknown.
sal_uInt32 readUINT32(const sal_uInt8 *buffer, sal_uInt32 &v)
css::uno::Any const & rValue
RegError getUnicodeListValue(std::u16string_view valueName, sal_Unicode ***pValueList, sal_uInt32 *pLen) const
RegError getStringListValue(std::u16string_view valueName, char ***pValueList, sal_uInt32 *pLen) const
RegError setLongListValue(std::u16string_view valueName, sal_Int32 const *pValueList, sal_uInt32 len)
RegError setStringListValue(std::u16string_view valueName, char **pValueList, sal_uInt32 len)
storeError readAt(sal_uInt32 nOffset, void *pBuffer, sal_uInt32 nBytes, sal_uInt32 &rnDone)
enum SAL_DLLPUBLIC_RTTI RegError
specifies the possible error codes which can occur using the registry API.
storeError first(iterator &it)
sal_uInt32 readUtf8(const sal_uInt8 *buffer, char *v, sal_uInt32 maxSize)
BINARY
The key has a value of type binary.
RegError closeKey(RegKeyHandle hKey)
SET_VALUE_FAILED
setting the specified value of a key failed.
enum SAL_DLLPUBLIC_RTTI RegValueType
defines the type of a key value.
VALUE_NOT_EXISTS
the key has no value
RegError getKeyNames(const OUString &keyName, rtl_uString ***pSubKeyNames, sal_uInt32 *pnSubKeys)
storeError create(storeFileHandle hFile, OUString const &rPath, OUString const &rName, storeAccessMode eMode)
RegError getValue(std::u16string_view valueName, RegValue value) const
store::OStoreDirectory getStoreDir() const
sal_uInt32 writeString(sal_uInt8 *buffer, const sal_Unicode *v)
storeError writeAt(sal_uInt32 nOffset, void const *pBuffer, sal_uInt32 nBytes, sal_uInt32 &rnDone)
INVALID_KEYNAME
the keyname is invalid.
RegError createKey(const OUString &keyName, RegKeyHandle *phNewKey)
sal_uInt32 countSubKeys()
sal_uInt32 readINT32(const sal_uInt8 *buffer, sal_Int32 &v)
RegError setValue(std::u16string_view valueName, RegValueType vType, RegValue value, sal_uInt32 vSize)
sal_uInt32 writeINT32(sal_uInt8 *buffer, sal_Int32 v)
sal_uInt32 readString(const sal_uInt8 *buffer, sal_Unicode *v, sal_uInt32 maxSize)
INVALID_VALUE
the key has an invalid value or the value type is unknown.
sal_Unicode m_pszName[STORE_MAXIMUM_NAMESIZE]
RegError getLongListValue(std::u16string_view valueName, sal_Int32 **pValueList, sal_uInt32 *pLen) const
#define SAL_WARN_IF(condition, area, stream)
void * RegKeyHandle
defines the type of a registry key handle used in the C API.
REGISTRY_READONLY
registry is open with readonly access rights.
RegError releaseKey(RegKeyHandle hKey)
RegError closeKey(RegKeyHandle hKey)
sal_uInt32 writeUtf8(sal_uInt8 *buffer, const char *v)
sal_uInt32 writeUINT32(sal_uInt8 *buffer, sal_uInt32 v)
void * RegValue
defines the type of a registry key value handle used in the C API.
RegError getValueInfo(std::u16string_view valueName, RegValueType *pValueTye, sal_uInt32 *pValueSize) const
void setModified(bool bModified=true)
RegError openKey(const OUString &keyName, RegKeyHandle *phOpenKey)
const store::OStoreFile & getStoreFile() const
const store::OStoreFile & getStoreFile() const
OUString getFullPath(OUString const &path) const
storeError next(iterator &it)
RegError openKey(RegKeyHandle hKey, const OUString &keyName, RegKeyHandle *phOpenKey)