42#include <osl/thread.h>
43#include <rtl/ustring.hxx>
44#include <rtl/ustrbuf.hxx>
45#include <osl/file.hxx>
53void printString(std::u16string_view s) {
55 for (std::size_t i = 0;
i < s.size(); ++
i) {
57 if (c ==
'"' || c ==
'\\') {
58 printf(
"\\%c",
static_cast< char >(c));
59 }
else if (s[i] >=
' ' && s[i] <=
'~') {
60 printf(
"%c",
static_cast< char >(c));
62 printf(
"\\u%04X",
static_cast< unsigned int >(c));
68void printFieldOrReferenceFlag(
86 printFieldOrReferenceFlag(
88 printFieldOrReferenceFlag(
90 printFieldOrReferenceFlag(
93 printFieldOrReferenceFlag(
95 printFieldOrReferenceFlag(
97 printFieldOrReferenceFlag(
99 printFieldOrReferenceFlag(
101 printFieldOrReferenceFlag(
103 printFieldOrReferenceFlag(
105 printFieldOrReferenceFlag(
108 printFieldOrReferenceFlag(
110 printFieldOrReferenceFlag(
112 printFieldOrReferenceFlag(
118 printf(
"<invalid (0x%04X)>",
static_cast< unsigned int >(flags));
125 printf(
"version: %ld\n",
static_cast< long >(reader.
getVersion()));
126 printf(
"%sdocumentation: ", indent.getStr());
129 printf(
"%sfile name: ", indent.getStr());
132 printf(
"%stype class: ", indent.getStr());
134 printf(
"published ");
175 "<invalid (%ld)>",
static_cast< long >(reader.
getTypeClass()));
179 printf(
"%stype name: ", indent.getStr());
183 "%ssuper type count: %u\n", indent.getStr(),
187 "%ssuper type name %u: ", indent.getStr(),
188 static_cast< unsigned int >(i));
193 "%sfield count: %u\n", indent.getStr(),
197 "%sfield %u:\n", indent.getStr(),
198 static_cast< unsigned int >(i));
199 printf(
"%s documentation: ", indent.getStr());
202 printf(
"%s file name: ", indent.getStr());
205 printf(
"%s flags: ", indent.getStr());
208 printf(
"%s name: ", indent.getStr());
211 printf(
"%s type name: ", indent.getStr());
214 printf(
"%s value: ", indent.getStr());
216 switch (
value.m_type) {
222 printf(
"boolean %s",
value.m_value.aBool ?
"true" :
"false");
226 printf(
"byte %d",
static_cast< int >(
value.m_value.aByte));
230 printf(
"short %d",
static_cast< int >(
value.m_value.aShort));
236 static_cast< unsigned int >(
value.m_value.aUShort));
240 printf(
"long %ld",
static_cast< long >(
value.m_value.aLong));
246 static_cast< unsigned long >(
value.m_value.aULong));
256 printf(
"unsigned hyper");
271 printString(
value.m_value.aString);
275 printf(
"<invalid (%ld)>",
static_cast< long >(
value.m_type));
281 "%smethod count: %u\n", indent.getStr(),
285 "%smethod %u:\n", indent.getStr(),
286 static_cast< unsigned int >(i));
287 printf(
"%s documentation: ", indent.getStr());
290 printf(
"%s flags: ", indent.getStr());
297 printf(
"synchronous");
301 printf(
"attribute get");
305 printf(
"attribute set");
315 printf(
"%s name: ", indent.getStr());
318 printf(
"%s return type name: ", indent.getStr());
322 "%s parameter count: %u\n", indent.getStr(),
328 "%s parameter %u:\n", indent.getStr(),
329 static_cast< unsigned int >(j));
330 printf(
"%s flags: ", indent.getStr());
347 printf(
"<invalid (%ld)>",
static_cast< long >(flags));
355 printf(
"%s name: ", indent.getStr());
358 printf(
"%s type name: ", indent.getStr());
363 "%s exception count: %u\n", indent.getStr(),
369 "%s exception type name %u: ", indent.getStr(),
370 static_cast< unsigned int >(j));
376 "%sreference count: %u\n", indent.getStr(),
380 "%sreference %u:\n", indent.getStr(),
381 static_cast< unsigned int >(i));
382 printf(
"%s documentation: ", indent.getStr());
385 printf(
"%s flags: ", indent.getStr());
388 printf(
"%s sort: ", indent.getStr());
399 printf(
"type parameter");
409 printf(
"%s type name: ", indent.getStr());
414 printf(
"<invalid>\n");
430 if (pRootKey !=
nullptr)
446 sAccessMode = storeAccessMode::Create;
450 sAccessMode = storeAccessMode::ReadOnly;
454 if (regName.isEmpty() &&
455 storeAccessMode::Create == sAccessMode)
461 errCode = rRegFile.
create(regName, sAccessMode);
482 storeError _err = rStoreDir.
create(rRegFile, OUString(), OUString(), sAccessMode);
520 if (!regName.isEmpty())
522 std::unique_ptr<ORegistry> pReg(
new ORegistry());
529 if (FileBase::getSystemPathFromFileURL(regName, systemName) != FileBase::E_None)
530 systemName = regName;
533 if (unlink(
name.getStr()) != 0)
557 if (FileBase::getSystemPathFromFileURL(
m_name, systemName) != FileBase::E_None)
561 if (unlink(
name.getStr()) != 0)
615 pKey =
static_cast<ORegKey*
>(hKey);
619 OUString sFullKeyName = pKey->
getFullPath(keyName);
630 OUStringBuffer sFullPath(sFullKeyName.getLength()+16);
633 sFullPath.append(
'/');
638 token = sFullKeyName.getToken(0,
'/',
nIndex);
639 if (!token.isEmpty())
641 if (rStoreDir.
create(pKey->
getStoreFile(), sFullPath.toString(), token, storeAccessMode::Create))
646 sFullPath.append(token +
"/");
651 pKey =
new ORegKey(sFullKeyName,
this);
663 *phOpenKey =
nullptr;
673 pKey =
static_cast<ORegKey*
>(hKey);
680 sal_Int32
n = path.lastIndexOf(
'/') + 1;
683 isReadOnly() ? storeAccessMode::ReadOnly : storeAccessMode::ReadWrite))
693 std::unique_ptr< ORegKey >
p(
new ORegKey(path,
this));
698 i->second->acquire();
700 *phOpenKey =
i->second;
710 OUString
const aKeyName (pKey->
getName());
717 if (pKey != pRootKey)
758 OUString sFullKeyName(pKey->
getName());
759 OUString sFullPath(sFullKeyName);
760 OUString sRelativKey;
761 size_t lastIndex = keyName.rfind(
'/');
763 if (lastIndex != std::u16string_view::npos)
765 sRelativKey += keyName.substr(lastIndex + 1);
767 if (sFullKeyName.getLength() > 1)
768 sFullKeyName += keyName;
770 sFullKeyName += keyName.substr(1);
772 sFullPath = sFullKeyName.copy(0, keyName.rfind(
'/') + 1);
775 if (sFullKeyName.getLength() > 1)
776 sFullKeyName +=
ROOT;
778 sRelativKey += keyName;
779 sFullKeyName += keyName;
781 if (sFullPath.getLength() > 1)
797 OUString tmpName = sRelativKey +
ROOT;
831 OUString sFullPath(pKey->
getName());
833 if (sFullPath.getLength() > 1)
843 _err = rStoreDir.
next(iter);
866 fprintf(stdout,
"Registry \"%s\":\n\n%s\n", regName.getStr(), keyName.getStr());
885 _err = rStoreDir.
next(iter);
894 sal_uInt32 valueSize;
896 OUString sFullPath(sPath);
902 accessMode = storeAccessMode::ReadOnly;
905 for (
int i= 0;
i < nSpc;
i++) sIndent +=
" ";
907 if (sFullPath.getLength() > 1)
921 return RegError::INVALID_VALUE;
925 return RegError::INVALID_VALUE;
935 return RegError::INVALID_VALUE;
937 if (rwBytes != valueSize)
939 return RegError::INVALID_VALUE;
942 const char* indent = sIndent.getStr();
946 fprintf(stdout,
"%sValue: Type = VALUETYPE_NOT_DEFINED\n", indent);
950 fprintf(stdout,
"%sValue: Type = RegValueType::LONG\n", indent);
952 stdout,
"%s Size = %lu\n", indent,
953 sal::static_int_cast< unsigned long >(valueSize));
954 fprintf(stdout,
"%s Data = ", indent);
958 fprintf(stdout,
"%ld\n", sal::static_int_cast< long >(
value));
963 char*
value =
static_cast<char*
>(std::malloc(valueSize));
965 fprintf(stdout,
"%sValue: Type = RegValueType::STRING\n", indent);
967 stdout,
"%s Size = %lu\n", indent,
968 sal::static_int_cast< unsigned long >(valueSize));
969 fprintf(stdout,
"%s Data = \"%s\"\n", indent,
value);
976 fprintf(stdout,
"%sValue: Type = RegValueType::UNICODE\n", indent);
978 stdout,
"%s Size = %lu\n", indent,
979 sal::static_int_cast< unsigned long >(valueSize));
980 fprintf(stdout,
"%s Data = ", indent);
985 OString uStr(
value.get(), rtl_ustr_getLength(
value.get()), RTL_TEXTENCODING_UTF8);
986 fprintf(stdout,
"L\"%s\"\n", uStr.getStr());
991 fprintf(stdout,
"%sValue: Type = RegValueType::BINARY\n", indent);
993 stdout,
"%s Size = %lu\n", indent,
994 sal::static_int_cast< unsigned long >(valueSize));
995 fprintf(stdout,
"%s Data = ", indent);
1003 sal_uInt32 offset = 4;
1008 fprintf(stdout,
"%sValue: Type = RegValueType::LONGLIST\n", indent);
1010 stdout,
"%s Size = %lu\n", indent,
1011 sal::static_int_cast< unsigned long >(valueSize));
1013 stdout,
"%s Len = %lu\n", indent,
1014 sal::static_int_cast< unsigned long >(len));
1015 fprintf(stdout,
"%s Data = ", indent);
1017 sal_Int32 longValue;
1018 for (sal_uInt32
i=0;
i < len;
i++)
1023 fprintf(stdout,
"%s ", indent);
1026 stdout,
"%lu = %ld\n",
1027 sal::static_int_cast< unsigned long >(
i),
1028 sal::static_int_cast< long >(longValue));
1035 sal_uInt32 offset = 4;
1036 sal_uInt32 sLen = 0;
1041 fprintf(stdout,
"%sValue: Type = RegValueType::STRINGLIST\n", indent);
1043 stdout,
"%s Size = %lu\n", indent,
1044 sal::static_int_cast< unsigned long >(valueSize));
1046 stdout,
"%s Len = %lu\n", indent,
1047 sal::static_int_cast< unsigned long >(len));
1048 fprintf(stdout,
"%s Data = ", indent);
1050 for (sal_uInt32
i=0;
i < len;
i++)
1056 char *pValue =
static_cast<char*
>(std::malloc(sLen));
1060 fprintf(stdout,
"%s ", indent);
1063 stdout,
"%lu = \"%s\"\n",
1064 sal::static_int_cast< unsigned long >(
i), pValue);
1070 case RegValueType::UNICODELIST:
1072 sal_uInt32 offset = 4;
1073 sal_uInt32 sLen = 0;
1078 fprintf(stdout,
"%sValue: Type = RegValueType::UNICODELIST\n", indent);
1080 stdout,
"%s Size = %lu\n", indent,
1081 sal::static_int_cast< unsigned long >(valueSize));
1083 stdout,
"%s Len = %lu\n", indent,
1084 sal::static_int_cast< unsigned long >(len));
1085 fprintf(stdout,
"%s Data = ", indent);
1088 for (sal_uInt32
i=0;
i < len;
i++)
1098 fprintf(stdout,
"%s ", indent);
1100 uStr = OString(pValue, rtl_ustr_getLength(pValue), RTL_TEXTENCODING_UTF8);
1102 stdout,
"%lu = L\"%s\"\n",
1103 sal::static_int_cast< unsigned long >(
i),
1114 fprintf(stdout,
"\n");
1122 OUString sFullPath(sPath);
1129 accessMode = storeAccessMode::ReadOnly;
1132 for (
int i= 0;
i < nSpace;
i++) sIndent +=
" ";
1134 if (sFullPath.getLength() > 1)
1146 OUString sSubPath(sFullPath);
1152 _err = rStoreDir.
first(iter);
1160 _ret =
dumpKey(sSubPath, sSubName, nSpace+2);
1163 _ret =
dumpValue(sSubPath, sSubName, nSpace+2);
1171 _err = rStoreDir.
next(iter);
void setModified(bool bModified=true)
OUString getFullPath(std::u16string_view path) const
const store::OStoreFile & getStoreFile() const
void setDeleted(bool bKeyDeleted)
RegError openKey(std::u16string_view keyName, RegKeyHandle *phOpenKey)
RegError closeKey(RegKeyHandle hKey)
const OUString & getName() const
store::OStoreDirectory getStoreDir() const
RegError dumpKey(const OUString &sPath, const OUString &sName, sal_Int16 nSpace) const
RegError initRegistry(const OUString &name, RegAccessMode accessMode, bool bCreate=false)
RegError closeKey(RegKeyHandle hKey)
RegError openKey(RegKeyHandle hKey, std::u16string_view keyName, RegKeyHandle *phOpenKey)
RegError eraseKey(ORegKey *pKey, std::u16string_view keyName)
RegError dumpRegistry(RegKeyHandle hKey) const
RegError dumpValue(const OUString &sPath, const OUString &sName, sal_Int16 nSpace) const
RegError deleteKey(RegKeyHandle hKey, std::u16string_view keyName)
RegError acquireKey(RegKeyHandle hKey)
const OUString & getName() const
RegError destroyRegistry(const OUString &name)
static constexpr OUStringLiteral ROOT
RegError deleteSubkeysAndValues(ORegKey *pKey)
RegError createKey(RegKeyHandle hKey, std::u16string_view keyName, RegKeyHandle *phNewKey)
RegError releaseKey(RegKeyHandle hKey)
specifies a helper class for const values.
storeError next(iterator &it)
storeError create(storeFileHandle hFile, OUString const &rPath, OUString const &rName, storeAccessMode eMode)
storeError first(iterator &it)
storeError createInMemory()
storeError create(OUString const &rFilename, storeAccessMode eAccessMode)
storeError remove(OUString const &rPath, OUString const &rName)
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)
A type reader working on a binary blob that represents a UNOIDL type.
OUString getFieldDocumentation(sal_uInt16 index) const
Returns the documentation of a field of this type reader.
OUString getSuperTypeName(sal_uInt16 index) const
Returns the type name of a super type of this type reader.
sal_uInt16 getSuperTypeCount() const
Returns the number of super types of this type reader.
OUString getFileName() const
Returns the file name of this type reader.
typereg_Version getVersion() const
Returns the binary blob version of this type reader.
RTConstValue getFieldValue(sal_uInt16 index) const
Returns the value of a field of this type reader.
sal_uInt16 getMethodParameterCount(sal_uInt16 index) const
Returns the number of parameters of a method of this type reader.
OUString getMethodName(sal_uInt16 index) const
Returns the name of a method of this type reader.
OUString getReferenceTypeName(sal_uInt16 index) const
Returns the type name of a reference of this type reader.
OUString getFieldFileName(sal_uInt16 index) const
Returns the file name of a field of this type reader.
OUString getMethodParameterName(sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
Returns the name of a parameter of a method of this type reader.
OUString getDocumentation() const
Returns the documentation of this type reader.
RTParamMode getMethodParameterFlags(sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
Returns the flags of a parameter of a method of this type reader.
RTMethodMode getMethodFlags(sal_uInt16 index) const
Returns the flags of a method of this type reader.
sal_uInt16 getMethodExceptionCount(sal_uInt16 index) const
Returns the number of exceptions of a method of this type reader.
OUString getTypeName() const
Returns the type name of this type reader.
bool isPublished() const
Returns whether this type reader is published.
OUString getReferenceDocumentation(sal_uInt16 index) const
Returns the documentation of a reference of this type reader.
OUString getMethodDocumentation(sal_uInt16 index) const
Returns the documentation of a method of this type reader.
RTFieldAccess getReferenceFlags(sal_uInt16 index) const
Returns the flags of a reference of this type reader.
OUString getMethodExceptionTypeName(sal_uInt16 methodIndex, sal_uInt16 exceptionIndex) const
Returns the type name of an exception of a method of this type reader.
RTFieldAccess getFieldFlags(sal_uInt16 index) const
Returns the flags of a field of this type reader.
RTTypeClass getTypeClass() const
Returns the type class of this type reader.
OUString getFieldTypeName(sal_uInt16 index) const
Returns the type name of a field of this type reader.
OUString getMethodReturnTypeName(sal_uInt16 index) const
Returns the return type name of a method of this type reader.
sal_uInt16 getFieldCount() const
Returns the number of fields of this type reader.
OUString getFieldName(sal_uInt16 index) const
Returns the name of a field of this type reader.
OUString getMethodParameterTypeName(sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
Returns the type name of a parameter of a method of this type reader.
sal_uInt16 getReferenceCount() const
Returns the number of references of this type reader.
bool isValid() const
Returns whether this type reader is valid.
sal_uInt16 getMethodCount() const
Returns the number of methods of this type reader.
RTReferenceType getReferenceSort(sal_uInt16 index) const
Returns the sort of a reference of this type reader.
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
constexpr OUStringLiteral first
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
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 readUtf8(const sal_uInt8 *buffer, char *v, sal_uInt32 maxSize)
#define VALUE_HEADEROFFSET
STRINGLIST
The key has a value of type ascii string list.
DESTROY_REGISTRY_FAILED
destroy a registry failed. There are may be any open keys.
INVALID_REGISTRY
registry is in an invalid state or the registry does not point to a valid registry data file.
VALUE_NOT_EXISTS
the key has no value
void * RegKeyHandle
defines the type of a registry key handle used in the C API.
KEY_NOT_OPEN
the key or key handle points to an invalid key or closed key.
UNICODE
The key has a value of type unicode string.
INVALID_KEY
the key is not in a valid state.
RegAccessMode
defines the open/access mode of the registry.
@ READWRITE
This mode allows readonly access.
REGISTRY_NOT_EXISTS
registry does not exists.
NOT_DEFINED
The key has no value or the value type is unknown.
CANNOT_OPEN_FOR_READWRITE
registry cannot be opened with readwrite access because the registry is already open with readwrite a...
INVALID_KEYNAME
the keyname is invalid.
DELETE_KEY_FAILED
the specified key cannot be deleted. Maybe an open key handle exists to this key.
enum SAL_DLLPUBLIC_RTTI RegValueType
defines the type of a key value.
CREATE_KEY_FAILED
the key with the specified keyname cannot be created.
DELETE_VALUE_FAILED
deleting of the key value failed.
LONGLIST
The key has a value of type long list.
KEY_NOT_EXISTS
the specified keyname points to a nonexisting key.
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
@ TYPE_PARAMETER
Indicates a type parameter of a polymorphic struct type template.
@ EXPORTS
the service exports the specified service that means this service provides also the specified service...
@ SUPPORTS
the service support the interface that means an implementation of this service must implement this in...
RTParamMode
specifies the mode of a parameter.
@ RT_PARAM_INOUT
indicates a in and out parameter which is used also by reference
@ RT_PARAM_REST
Indicates a rest parameter (currently only valid for service constructors).
@ RT_PARAM_IN
indicates a pure in parameter which is used by value
@ RT_PARAM_OUT
indicates a pure out parameter which is used by reference
RTFieldAccess
specifies the type for the field access.
@ READWRITE
specifies that the property/attribute has read/write access
@ READONLY
specifies a readonly property/attribute
@ PROPERTY
specifies that the field is a property
@ OPTIONAL
specifies a property as optional that means that it must not be implemented.
@ PUBLISHED
Flag for published individual constants.
@ PARAMETERIZED_TYPE
Indicates that a member of a polymorphic struct type template is of a parameterized type.
@ CONST
specifies that the field is a constant or enum value
@ ATTRIBUTE_GET
Indicates an extended attribute getter (that has a 'raises' clause) of an interface type.
@ ATTRIBUTE_SET
Indicates an extended attribute setter (that has a 'raises' clause) of an interface type.
@ ONEWAY
indicates the asynchronous mode of a method
@ TWOWAY
indicated the synchronous mode of a method
@ RT_TYPE_INTERFACE
specifies that the blob represents an interface type.
@ RT_TYPE_MODULE
specifies that the blob represents a module type.
@ RT_TYPE_CONSTANTS
specifies that the blob represents a constants type.
@ RT_TYPE_STRUCT
specifies that the blob represents a struct type.
@ RT_TYPE_SINGLETON
specifies that the blob represents a singleton type (a named object) which refers exactly one existin...
@ RT_TYPE_SERVICE
specifies that the blob represents a service type.
@ RT_TYPE_EXCEPTION
specifies that the blob represents an exception type.
@ RT_TYPE_ENUM
specifies that the blob represents an enum type.
@ RT_TYPE_TYPEDEF
specifies that the blob represents a typedef type.
std::unique_ptr< char[]> aBuffer