summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cppuhelper/source/servicemanager.cxx2
-rw-r--r--include/registry/registry.h2
-rw-r--r--include/registry/registry.hxx2
-rw-r--r--include/registry/regtype.h20
-rw-r--r--registry/source/regimpl.cxx12
-rw-r--r--registry/source/regimpl.hxx5
-rw-r--r--registry/source/registry.cxx4
-rw-r--r--registry/test/testregcpp.cxx10
-rw-r--r--registry/tools/regcompare.cxx4
-rw-r--r--registry/tools/regmerge.cxx2
-rw-r--r--registry/tools/regview.cxx2
-rw-r--r--registry/workben/regtest.cxx6
-rw-r--r--stoc/source/simpleregistry/simpleregistry.cxx2
-rw-r--r--stoc/test/testregistry.cxx4
-rw-r--r--stoc/test/testsmgr.cxx2
-rw-r--r--unoidl/source/legacyprovider.cxx2
16 files changed, 42 insertions, 39 deletions
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index 8a2cdcab2833..08d99bd9c779 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -1451,7 +1451,7 @@ void cppuhelper::ServiceManager::readRdbFile(
bool cppuhelper::ServiceManager::readLegacyRdbFile(rtl::OUString const & uri) {
Registry reg;
- switch (reg.open(uri, REG_READONLY)) {
+ switch (reg.open(uri, RegAccessMode::READONLY)) {
case REG_NO_ERROR:
break;
case REG_REGISTRY_NOT_EXISTS:
diff --git a/include/registry/registry.h b/include/registry/registry.h
index b4add7f9bd53..15e6c9dd42ff 100644
--- a/include/registry/registry.h
+++ b/include/registry/registry.h
@@ -411,7 +411,7 @@ REG_DLLPUBLIC sal_Bool REGISTRY_CALLTYPE reg_isReadOnly(RegHandle hReg);
@param registryName points to a null terminated string specifying the name of the registry.
@param phRegistry points to a hanle of the opened registry if the function succeeds otherwise NULL.
- @param accessMode specifies the accessmode of the registry, REG_READONLY or REG_READWRITE.
+ @param accessMode specifies the accessmode of the registry, RegAccessMode::READONLY or RegAccessMode::READWRITE.
@return REG_NO_ERROR if succeeds else an error code.
*/
REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_openRegistry(rtl_uString* registryName,
diff --git a/include/registry/registry.hxx b/include/registry/registry.hxx
index de511c0fb39f..7f023a0504a9 100644
--- a/include/registry/registry.hxx
+++ b/include/registry/registry.hxx
@@ -136,7 +136,7 @@ public:
If the registry already points to a valid registry, the old registry will be closed.
@param registryName specifies a registry name.
- @param accessMode specifies the access mode for the registry, REG_READONLY or REG_READWRITE.
+ @param accessMode specifies the access mode for the registry, RegAccessMode::READONLY or RegAccessMode::READWRITE.
@return REG_NO_ERROR if succeeds else an error code.
*/
inline RegError open(const rtl::OUString& registryName,
diff --git a/include/registry/regtype.h b/include/registry/regtype.h
index 79c3d993537d..9ae76a8a4288 100644
--- a/include/registry/regtype.h
+++ b/include/registry/regtype.h
@@ -21,6 +21,7 @@
#define INCLUDED_REGISTRY_REGTYPE_H
#include <sal/types.h>
+#include <o3tl/typed_flags_set.hxx>
/// defines the type of a registry handle used in the C API.
typedef void* RegHandle;
@@ -34,15 +35,18 @@ typedef void* RegValue;
/** defines the open/access mode of the registry.
Two modes are valid:
- -REG_READONLY allows readonly access
- -REG_READWRITE allows read and write access
+ -READONLY allows readonly access
+ -READWRITE allows read and write access
*/
-typedef sal_uInt16 RegAccessMode;
-
-/// Flag to specify the open mode of a registry. This mode allows readonly access.
-#define REG_READONLY 0x0001
-/// Flag to specify the open mode of a registry. This mode allows read and write access.
-#define REG_READWRITE 0x0002
+enum class RegAccessMode
+{
+ READONLY = 0x0001, /// This mode allows readonly access.
+ READWRITE = 0x0002 /// This mode allows read and write access.
+};
+namespace o3tl
+{
+ template<> struct typed_flags<RegAccessMode> : is_typed_flags<RegAccessMode, 0x07> {};
+}
/** defines the type of a registry key.
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 6c0bba1fac47..876245a0d366 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -452,18 +452,18 @@ ORegistry::~ORegistry()
// initRegistry
-RegError ORegistry::initRegistry(const OUString& regName, RegAccessMode accessMode)
+RegError ORegistry::initRegistry(const OUString& regName, RegAccessMode accessMode, bool bCreate)
{
RegError eRet = REG_INVALID_REGISTRY;
OStoreFile rRegFile;
storeAccessMode sAccessMode = REG_MODE_OPEN;
storeError errCode;
- if (accessMode & REG_CREATE)
+ if (bCreate)
{
sAccessMode = REG_MODE_CREATE;
}
- else if (accessMode & REG_READONLY)
+ else if (accessMode & RegAccessMode::READONLY)
{
sAccessMode = REG_MODE_OPENREAD;
m_readOnly = true;
@@ -547,7 +547,7 @@ RegError ORegistry::destroyRegistry(const OUString& regName)
{
std::unique_ptr<ORegistry> pReg(new ORegistry());
- if (!pReg->initRegistry(regName, REG_READWRITE))
+ if (!pReg->initRegistry(regName, RegAccessMode::READWRITE))
{
pReg.reset();
@@ -908,7 +908,7 @@ RegError ORegistry::loadKey(RegKeyHandle hKey, const OUString& regFileName,
ORegKey* pKey = static_cast< ORegKey* >(hKey);
std::unique_ptr< ORegistry > pReg (new ORegistry());
- _ret = pReg->initRegistry(regFileName, REG_READONLY);
+ _ret = pReg->initRegistry(regFileName, RegAccessMode::READONLY);
if (_ret != REG_NO_ERROR)
return _ret;
ORegKey* pRootKey = pReg->getRootKey();
@@ -956,7 +956,7 @@ RegError ORegistry::saveKey(RegKeyHandle hKey, const OUString& regFileName,
ORegKey* pKey = static_cast< ORegKey* >(hKey);
std::unique_ptr< ORegistry > pReg (new ORegistry());
- _ret = pReg->initRegistry(regFileName, REG_CREATE);
+ _ret = pReg->initRegistry(regFileName, RegAccessMode::READWRITE, true/*bCreate*/);
if (_ret != REG_NO_ERROR)
return _ret;
ORegKey* pRootKey = pReg->getRootKey();
diff --git a/registry/source/regimpl.hxx b/registry/source/regimpl.hxx
index 3dc88987a29a..6d38cb796947 100644
--- a/registry/source/regimpl.hxx
+++ b/registry/source/regimpl.hxx
@@ -48,8 +48,6 @@
#define VALUE_TYPEOFFSET 1
#define VALUE_HEADEROFFSET 5
-#define REG_CREATE 0x0004 // allow write accesses
-
#define REG_GUARD(mutex) \
osl::Guard< osl::Mutex > aGuard( mutex );
@@ -68,7 +66,8 @@ public:
{ return --m_refCount; }
RegError initRegistry(const OUString& name,
- RegAccessMode accessMode);
+ RegAccessMode accessMode,
+ bool bCreate = false);
RegError closeRegistry();
diff --git a/registry/source/registry.cxx b/registry/source/registry.cxx
index 163d9a35693b..f34f9e28e2ff 100644
--- a/registry/source/registry.cxx
+++ b/registry/source/registry.cxx
@@ -114,7 +114,7 @@ static RegError REGISTRY_CALLTYPE createRegistry(rtl_uString* registryName,
RegError ret;
ORegistry* pReg = new ORegistry();
- if ((ret = pReg->initRegistry(registryName, REG_CREATE)))
+ if ((ret = pReg->initRegistry(registryName, RegAccessMode::READWRITE, true/*bCreate*/)))
{
delete pReg;
*phRegistry = NULL;
@@ -508,7 +508,7 @@ RegError REGISTRY_CALLTYPE reg_createRegistry(rtl_uString* registryName,
RegError ret;
ORegistry* pReg = new ORegistry();
- if ((ret = pReg->initRegistry(registryName, REG_CREATE)))
+ if ((ret = pReg->initRegistry(registryName, RegAccessMode::READWRITE, true/*bCreate*/)))
{
delete pReg;
*phRegistry = NULL;
diff --git a/registry/test/testregcpp.cxx b/registry/test/testregcpp.cxx
index 532501d73859..1eb16831d31f 100644
--- a/registry/test/testregcpp.cxx
+++ b/registry/test/testregcpp.cxx
@@ -619,7 +619,7 @@ void test_registry_CppApi()
REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 32");
- REG_ENSURE(!myRegistry->open(OUString("test.rdb"), REG_READWRITE), "test_registry_CppApi error 33");
+ REG_ENSURE(!myRegistry->open(OUString("test.rdb"), RegAccessMode::READWRITE), "test_registry_CppApi error 33");
REG_ENSURE(!myRegistry->openRootKey(rootKey), "test_registry_CppApi error 34");
REG_ENSURE(!myRegistry->loadKey(rootKey, OUString("allFromTest2"),
@@ -659,7 +659,7 @@ void test_registry_CppApi()
REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 46");
- REG_ENSURE(!myRegistry->open(OUString("test.rdb"), REG_READWRITE), "test_registry_CppApi error 47");
+ REG_ENSURE(!myRegistry->open(OUString("test.rdb"), RegAccessMode::READWRITE), "test_registry_CppApi error 47");
REG_ENSURE(!myRegistry->destroy(OUString("test2.rdb")), "test_registry_CppApi error 48");
// REG_ENSURE(!myRegistry->destroy("test3.rdb"), "test_registry_CppApi error 49");
@@ -672,7 +672,7 @@ void test_registry_CppApi()
REG_ENSURE(!myRegistry->create(OUString("destroytest.rdb")), "test_registry_CppApi error 51");
REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 52");
- REG_ENSURE(!myRegistry->open(OUString("destroytest.rdb"), REG_READONLY), "test_registry_CppApi error 53");
+ REG_ENSURE(!myRegistry->open(OUString("destroytest.rdb"), RegAccessMode::READONLY), "test_registry_CppApi error 53");
REG_ENSURE(!myRegistry->openRootKey(rootKey), "test_registry_CppApi error 54");
REG_ENSURE(myRegistry->mergeKey(rootKey, OUString("allFromTest3"),
@@ -681,10 +681,10 @@ void test_registry_CppApi()
REG_ENSURE(!rootKey.closeKey(), "test_registry_CppApi error 57");
REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 58");
- REG_ENSURE(!myRegistry->open(OUString("destroytest.rdb"), REG_READWRITE), "test_registry_CppApi error 59");
+ REG_ENSURE(!myRegistry->open(OUString("destroytest.rdb"), RegAccessMode::READWRITE), "test_registry_CppApi error 59");
REG_ENSURE(!myRegistry->destroy(OUString()), "test_registry_CppApi error 60");
- REG_ENSURE(!myRegistry->open(OUString("test.rdb"), REG_READWRITE), "test_registry_CppApi error 61");
+ REG_ENSURE(!myRegistry->open(OUString("test.rdb"), RegAccessMode::READWRITE), "test_registry_CppApi error 61");
REG_ENSURE(!myRegistry->destroy(OUString("ucrtest.rdb")), "test_registry_CppApi error 62");
REG_ENSURE(!myRegistry->destroy(OUString()), "test_registry_CppApi error 63");
delete(myRegistry);
diff --git a/registry/tools/regcompare.cxx b/registry/tools/regcompare.cxx
index 032762d228ea..583b3f736c92 100644
--- a/registry/tools/regcompare.cxx
+++ b/registry/tools/regcompare.cxx
@@ -1975,13 +1975,13 @@ int _cdecl main( int argc, char * argv[] )
OUString regName2( convertToFileUrl(options.getRegName2().c_str(), options.getRegName2().size()) );
Registry reg1, reg2;
- if ( reg1.open(regName1, REG_READONLY) )
+ if ( reg1.open(regName1, RegAccessMode::READONLY) )
{
fprintf(stdout, "%s: open registry \"%s\" failed\n",
options.getProgramName().c_str(), options.getRegName1().c_str());
return 2;
}
- if ( reg2.open(regName2, REG_READONLY) )
+ if ( reg2.open(regName2, RegAccessMode::READONLY) )
{
fprintf(stdout, "%s: open registry \"%s\" failed\n",
options.getProgramName().c_str(), options.getRegName2().c_str());
diff --git a/registry/tools/regmerge.cxx b/registry/tools/regmerge.cxx
index 0a712cae987b..7a170d72f925 100644
--- a/registry/tools/regmerge.cxx
+++ b/registry/tools/regmerge.cxx
@@ -109,7 +109,7 @@ int __cdecl main( int argc, char * argv[] )
Registry reg;
OUString regName( convertToFileUrl(args[0].c_str(), args[0].size()) );
- if (reg.open(regName, REG_READWRITE) != REG_NO_ERROR)
+ if (reg.open(regName, RegAccessMode::READWRITE) != REG_NO_ERROR)
{
if (reg.create(regName) != REG_NO_ERROR)
{
diff --git a/registry/tools/regview.cxx b/registry/tools/regview.cxx
index 16b1b17a5060..6930a8fcc073 100644
--- a/registry/tools/regview.cxx
+++ b/registry/tools/regview.cxx
@@ -44,7 +44,7 @@ int __cdecl main( int argc, char * argv[] )
}
OUString regName( convertToFileUrl(argv[1], strlen(argv[1])) );
- if (reg_openRegistry(regName.pData, &hReg, REG_READONLY))
+ if (reg_openRegistry(regName.pData, &hReg, RegAccessMode::READONLY))
{
fprintf(stderr, "open registry \"%s\" failed\n", argv[1]);
exit(1);
diff --git a/registry/workben/regtest.cxx b/registry/workben/regtest.cxx
index 7b590774c1ce..2a891f7a0b6a 100644
--- a/registry/workben/regtest.cxx
+++ b/registry/workben/regtest.cxx
@@ -232,7 +232,7 @@ int _cdecl main()
else
cout << "30. registry test5.rdb is closed\n";
- if (reg_openRegistry(OUString("test4.rdb").pData, &hReg, REG_READWRITE))
+ if (reg_openRegistry(OUString("test4.rdb").pData, &hReg, RegAccessMode::READWRITE))
cout << "\t31. registry test4.rdb is opened\n";
else
cout << "31. registry test4.rdb is opened\n";
@@ -293,13 +293,13 @@ int _cdecl main()
else
cout << "\n43. key \"/allFromTest3/reg2FirstKey/reg2FirstSubKey\" is deleted\n";
- if (reg_openRegistry(OUString("test4.rdb").pData, &hReg2, REG_READONLY))
+ if (reg_openRegistry(OUString("test4.rdb").pData, &hReg2, RegAccessMode::READONLY))
cout << "\n\t44. registry test4.rdb is opened for read only\n";
else
cout << "\n44. registry test4.rdb is opened for read only\n";
RegHandle hReg3;
- if (reg_openRegistry(OUString("test4.rdb").pData, &hReg3, REG_READONLY))
+ if (reg_openRegistry(OUString("test4.rdb").pData, &hReg3, RegAccessMode::READONLY))
cout << "\n\t44.a). registry test4.rdb is opened for read only\n";
else
cout << "\n44.a). registry test4.rdb is opened for read only\n";
diff --git a/stoc/source/simpleregistry/simpleregistry.cxx b/stoc/source/simpleregistry/simpleregistry.cxx
index 12faa50b1838..122cee8410e0 100644
--- a/stoc/source/simpleregistry/simpleregistry.cxx
+++ b/stoc/source/simpleregistry/simpleregistry.cxx
@@ -1018,7 +1018,7 @@ void SimpleRegistry::open(
osl::MutexGuard guard(mutex_);
RegError err = (rURL.isEmpty() && bCreate)
? REG_REGISTRY_NOT_EXISTS
- : registry_.open(rURL, bReadOnly ? REG_READONLY : REG_READWRITE);
+ : registry_.open(rURL, bReadOnly ? RegAccessMode::READONLY : RegAccessMode::READWRITE);
if (err == REG_REGISTRY_NOT_EXISTS && bCreate) {
err = registry_.create(rURL);
}
diff --git a/stoc/test/testregistry.cxx b/stoc/test/testregistry.cxx
index 763619ae33a4..df7e2826b7e7 100644
--- a/stoc/test/testregistry.cxx
+++ b/stoc/test/testregistry.cxx
@@ -107,7 +107,7 @@ RegistryKey rootKey, rKey, rKey2;
OUString userReg = getExePath();
userReg += "user.rdb";
-if(myRegistry->open(userReg, REG_READWRITE))
+if(myRegistry->open(userReg, RegAccessMode::READWRITE))
{
OSL_VERIFY(!myRegistry->create(userReg));
}
@@ -128,7 +128,7 @@ void setLinkInDefaultRegistry(const OUString& linkName, const OUString& linkTarg
OUString appReg = getExePath();
appReg += "stoctest.rdb";
- OSL_VERIFY(!myRegistry->open(appReg, REG_READWRITE));
+ OSL_VERIFY(!myRegistry->open(appReg, RegAccessMode::READWRITE));
OSL_VERIFY(!myRegistry->openRootKey(rootKey));
OSL_VERIFY(!rootKey.createLink(linkName, linkTarget));
diff --git a/stoc/test/testsmgr.cxx b/stoc/test/testsmgr.cxx
index a6097e04491b..666d16fa5f92 100644
--- a/stoc/test/testsmgr.cxx
+++ b/stoc/test/testsmgr.cxx
@@ -63,7 +63,7 @@ void setStarUserRegistry()
OUString userReg = getExePath();
userReg += "user.rdb";
- if(myRegistry->open(userReg, REG_READWRITE))
+ if(myRegistry->open(userReg, RegAccessMode::READWRITE))
{
OSL_VERIFY(!myRegistry->create(userReg));
}
diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx
index cad04e6887d6..9d5675805dbc 100644
--- a/unoidl/source/legacyprovider.cxx
+++ b/unoidl/source/legacyprovider.cxx
@@ -796,7 +796,7 @@ LegacyProvider::LegacyProvider(Manager & manager, OUString const & uri):
manager_(manager)
{
Registry reg;
- RegError e = reg.open(uri, REG_READONLY);
+ RegError e = reg.open(uri, RegAccessMode::READONLY);
switch (e) {
case REG_NO_ERROR:
break;