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);
647 sFullPath.append(
'/');
652 pKey =
new ORegKey(sFullKeyName,
this);
664 *phOpenKey =
nullptr;
674 pKey =
static_cast<ORegKey*
>(hKey);
681 sal_Int32
n = path.lastIndexOf(
'/') + 1;
684 isReadOnly() ? storeAccessMode::ReadOnly : storeAccessMode::ReadWrite))
694 std::unique_ptr< ORegKey >
p(
new ORegKey(path,
this));
699 i->second->acquire();
701 *phOpenKey =
i->second;
711 OUString
const aKeyName (pKey->
getName());
718 if (pKey != pRootKey)
759 OUString sFullKeyName(pKey->
getName());
760 OUString sFullPath(sFullKeyName);
761 OUString sRelativKey;
762 size_t lastIndex = keyName.rfind(
'/');
764 if (lastIndex != std::u16string_view::npos)
766 sRelativKey += keyName.substr(lastIndex + 1);
768 if (sFullKeyName.getLength() > 1)
769 sFullKeyName += keyName;
771 sFullKeyName += keyName.substr(1);
773 sFullPath = sFullKeyName.copy(0, keyName.rfind(
'/') + 1);
776 if (sFullKeyName.getLength() > 1)
777 sFullKeyName +=
ROOT;
779 sRelativKey += keyName;
780 sFullKeyName += keyName;
782 if (sFullPath.getLength() > 1)
798 OUString tmpName = sRelativKey +
ROOT;
832 OUString sFullPath(pKey->
getName());
834 if (sFullPath.getLength() > 1)
844 _err = rStoreDir.
next(iter);
867 fprintf(stdout,
"Registry \"%s\":\n\n%s\n", regName.getStr(), keyName.getStr());
886 _err = rStoreDir.
next(iter);
895 sal_uInt32 valueSize;
897 OUString sFullPath(sPath);
903 accessMode = storeAccessMode::ReadOnly;
906 for (
int i= 0;
i < nSpc;
i++) sIndent +=
" ";
908 if (sFullPath.getLength() > 1)
938 if (rwBytes != valueSize)
943 const char* indent = sIndent.getStr();
947 fprintf(stdout,
"%sValue: Type = VALUETYPE_NOT_DEFINED\n", indent);
951 fprintf(stdout,
"%sValue: Type = RegValueType::LONG\n", indent);
953 stdout,
"%s Size = %lu\n", indent,
954 sal::static_int_cast< unsigned long >(valueSize));
955 fprintf(stdout,
"%s Data = ", indent);
959 fprintf(stdout,
"%ld\n", sal::static_int_cast< long >(
value));
964 char*
value =
static_cast<char*
>(std::malloc(valueSize));
966 fprintf(stdout,
"%sValue: Type = RegValueType::STRING\n", indent);
968 stdout,
"%s Size = %lu\n", indent,
969 sal::static_int_cast< unsigned long >(valueSize));
970 fprintf(stdout,
"%s Data = \"%s\"\n", indent,
value);
977 fprintf(stdout,
"%sValue: Type = RegValueType::UNICODE\n", indent);
979 stdout,
"%s Size = %lu\n", indent,
980 sal::static_int_cast< unsigned long >(valueSize));
981 fprintf(stdout,
"%s Data = ", indent);
986 OString uStr(
value.get(), rtl_ustr_getLength(
value.get()), RTL_TEXTENCODING_UTF8);
987 fprintf(stdout,
"L\"%s\"\n", uStr.getStr());
992 fprintf(stdout,
"%sValue: Type = RegValueType::BINARY\n", indent);
994 stdout,
"%s Size = %lu\n", indent,
995 sal::static_int_cast< unsigned long >(valueSize));
996 fprintf(stdout,
"%s Data = ", indent);
1004 sal_uInt32 offset = 4;
1009 fprintf(stdout,
"%sValue: Type = RegValueType::LONGLIST\n", indent);
1011 stdout,
"%s Size = %lu\n", indent,
1012 sal::static_int_cast< unsigned long >(valueSize));
1014 stdout,
"%s Len = %lu\n", indent,
1015 sal::static_int_cast< unsigned long >(len));
1016 fprintf(stdout,
"%s Data = ", indent);
1018 sal_Int32 longValue;
1019 for (sal_uInt32
i=0;
i < len;
i++)
1024 fprintf(stdout,
"%s ", indent);
1027 stdout,
"%lu = %ld\n",
1028 sal::static_int_cast< unsigned long >(
i),
1029 sal::static_int_cast< long >(longValue));
1036 sal_uInt32 offset = 4;
1037 sal_uInt32 sLen = 0;
1042 fprintf(stdout,
"%sValue: Type = RegValueType::STRINGLIST\n", indent);
1044 stdout,
"%s Size = %lu\n", indent,
1045 sal::static_int_cast< unsigned long >(valueSize));
1047 stdout,
"%s Len = %lu\n", indent,
1048 sal::static_int_cast< unsigned long >(len));
1049 fprintf(stdout,
"%s Data = ", indent);
1051 for (sal_uInt32
i=0;
i < len;
i++)
1057 char *pValue =
static_cast<char*
>(std::malloc(sLen));
1061 fprintf(stdout,
"%s ", indent);
1064 stdout,
"%lu = \"%s\"\n",
1065 sal::static_int_cast< unsigned long >(
i), pValue);
1071 case RegValueType::UNICODELIST:
1073 sal_uInt32 offset = 4;
1074 sal_uInt32 sLen = 0;
1079 fprintf(stdout,
"%sValue: Type = RegValueType::UNICODELIST\n", indent);
1081 stdout,
"%s Size = %lu\n", indent,
1082 sal::static_int_cast< unsigned long >(valueSize));
1084 stdout,
"%s Len = %lu\n", indent,
1085 sal::static_int_cast< unsigned long >(len));
1086 fprintf(stdout,
"%s Data = ", indent);
1089 for (sal_uInt32
i=0;
i < len;
i++)
1099 fprintf(stdout,
"%s ", indent);
1101 uStr = OString(pValue, rtl_ustr_getLength(pValue), RTL_TEXTENCODING_UTF8);
1103 stdout,
"%lu = L\"%s\"\n",
1104 sal::static_int_cast< unsigned long >(
i),
1115 fprintf(stdout,
"\n");
1123 OUString sFullPath(sPath);
1130 accessMode = storeAccessMode::ReadOnly;
1133 for (
int i= 0;
i < nSpace;
i++) sIndent +=
" ";
1135 if (sFullPath.getLength() > 1)
1147 OUString sSubPath(sFullPath);
1153 _err = rStoreDir.
first(iter);
1161 _ret =
dumpKey(sSubPath, sSubName, nSpace+2);
1164 _ret =
dumpValue(sSubPath, sSubName, nSpace+2);
1172 _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.
INVALID_VALUE
the key has an invalid value or the value type is unknown.
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