Avoid lambda being destroyed while it is being called.
[LibreOffice.git] / registry / source / regimpl.cxx
blob63c937a1109a7b8b9e76c3ac216097257532f08a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "regimpl.hxx"
23 #include <memory>
24 #include <set>
25 #include <vector>
26 #include <string.h>
27 #include <stdio.h>
29 #if defined(UNX)
30 #include <unistd.h>
31 #endif
33 #include "reflread.hxx"
35 #include "reflwrit.hxx"
37 #include <registry/reader.hxx>
38 #include <registry/refltype.hxx>
39 #include <registry/types.hxx>
41 #include "reflcnst.hxx"
42 #include "keyimpl.hxx"
44 #include <osl/thread.h>
45 #include <rtl/ustring.hxx>
46 #include <rtl/ustrbuf.hxx>
47 #include <osl/file.hxx>
49 using namespace osl;
50 using namespace store;
53 namespace {
55 void printString(OUString const & s) {
56 printf("\"");
57 for (sal_Int32 i = 0; i < s.getLength(); ++i) {
58 sal_Unicode c = s[i];
59 if (c == '"' || c == '\\') {
60 printf("\\%c", static_cast< char >(c));
61 } else if (s[i] >= ' ' && s[i] <= '~') {
62 printf("%c", static_cast< char >(c));
63 } else {
64 printf("\\u%04X", static_cast< unsigned int >(c));
67 printf("\"");
70 void printFieldOrReferenceFlag(
71 RTFieldAccess * flags, RTFieldAccess flag, char const * name, bool * first)
73 if ((*flags & flag) != RTFieldAccess::NONE) {
74 if (!*first) {
75 printf("|");
77 *first = false;
78 printf("%s", name);
79 *flags &= ~flag;
83 void printFieldOrReferenceFlags(RTFieldAccess flags) {
84 if (flags == RTFieldAccess::NONE) {
85 printf("none");
86 } else {
87 bool first = true;
88 printFieldOrReferenceFlag(
89 &flags, RTFieldAccess::READONLY, "readonly", &first);
90 printFieldOrReferenceFlag(
91 &flags, RTFieldAccess::OPTIONAL, "optional", &first);
92 printFieldOrReferenceFlag(
93 &flags, RTFieldAccess::MAYBEVOID, "maybevoid", &first);
94 printFieldOrReferenceFlag(&flags, RTFieldAccess::BOUND, "bound", &first);
95 printFieldOrReferenceFlag(
96 &flags, RTFieldAccess::CONSTRAINED, "constrained", &first);
97 printFieldOrReferenceFlag(
98 &flags, RTFieldAccess::TRANSIENT, "transient", &first);
99 printFieldOrReferenceFlag(
100 &flags, RTFieldAccess::MAYBEAMBIGUOUS, "maybeambiguous", &first);
101 printFieldOrReferenceFlag(
102 &flags, RTFieldAccess::MAYBEDEFAULT, "maybedefault", &first);
103 printFieldOrReferenceFlag(
104 &flags, RTFieldAccess::REMOVABLE, "removable", &first);
105 printFieldOrReferenceFlag(
106 &flags, RTFieldAccess::ATTRIBUTE, "attribute", &first);
107 printFieldOrReferenceFlag(
108 &flags, RTFieldAccess::PROPERTY, "property", &first);
109 printFieldOrReferenceFlag(&flags, RTFieldAccess::CONST, "const", &first);
110 printFieldOrReferenceFlag(
111 &flags, RTFieldAccess::READWRITE, "readwrite", &first);
112 printFieldOrReferenceFlag(
113 &flags, RTFieldAccess::PARAMETERIZED_TYPE, "parameterized type", &first);
114 printFieldOrReferenceFlag(
115 &flags, RTFieldAccess::PUBLISHED, "published", &first);
116 if (flags != RTFieldAccess::NONE) {
117 if (!first) {
118 printf("|");
120 printf("<invalid (0x%04X)>", static_cast< unsigned int >(flags));
125 void dumpType(typereg::Reader const & reader, OString const & indent) {
126 if (reader.isValid()) {
127 printf("version: %ld\n", static_cast< long >(reader.getVersion()));
128 printf("%sdocumentation: ", indent.getStr());
129 printString(reader.getDocumentation());
130 printf("\n");
131 printf("%sfile name: ", indent.getStr());
132 printString(reader.getFileName());
133 printf("\n");
134 printf("%stype class: ", indent.getStr());
135 if (reader.isPublished()) {
136 printf("published ");
138 switch (reader.getTypeClass()) {
139 case RT_TYPE_INTERFACE:
140 printf("interface");
141 break;
143 case RT_TYPE_MODULE:
144 printf("module");
145 break;
147 case RT_TYPE_STRUCT:
148 printf("struct");
149 break;
151 case RT_TYPE_ENUM:
152 printf("enum");
153 break;
155 case RT_TYPE_EXCEPTION:
156 printf("exception");
157 break;
159 case RT_TYPE_TYPEDEF:
160 printf("typedef");
161 break;
163 case RT_TYPE_SERVICE:
164 printf("service");
165 break;
167 case RT_TYPE_SINGLETON:
168 printf("singleton");
169 break;
171 case RT_TYPE_CONSTANTS:
172 printf("constants");
173 break;
175 default:
176 printf(
177 "<invalid (%ld)>", static_cast< long >(reader.getTypeClass()));
178 break;
180 printf("\n");
181 printf("%stype name: ", indent.getStr());
182 printString(reader.getTypeName());
183 printf("\n");
184 printf(
185 "%ssuper type count: %u\n", indent.getStr(),
186 static_cast< unsigned int >(reader.getSuperTypeCount()));
187 for (sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i) {
188 printf(
189 "%ssuper type name %u: ", indent.getStr(),
190 static_cast< unsigned int >(i));
191 printString(reader.getSuperTypeName(i));
192 printf("\n");
194 printf(
195 "%sfield count: %u\n", indent.getStr(),
196 static_cast< unsigned int >(reader.getFieldCount()));
197 for (sal_uInt16 i = 0; i < reader.getFieldCount(); ++i) {
198 printf(
199 "%sfield %u:\n", indent.getStr(),
200 static_cast< unsigned int >(i));
201 printf("%s documentation: ", indent.getStr());
202 printString(reader.getFieldDocumentation(i));
203 printf("\n");
204 printf("%s file name: ", indent.getStr());
205 printString(reader.getFieldFileName(i));
206 printf("\n");
207 printf("%s flags: ", indent.getStr());
208 printFieldOrReferenceFlags(reader.getFieldFlags(i));
209 printf("\n");
210 printf("%s name: ", indent.getStr());
211 printString(reader.getFieldName(i));
212 printf("\n");
213 printf("%s type name: ", indent.getStr());
214 printString(reader.getFieldTypeName(i));
215 printf("\n");
216 printf("%s value: ", indent.getStr());
217 RTConstValue value(reader.getFieldValue(i));
218 switch (value.m_type) {
219 case RT_TYPE_NONE:
220 printf("none");
221 break;
223 case RT_TYPE_BOOL:
224 printf("boolean %s", value.m_value.aBool ? "true" : "false");
225 break;
227 case RT_TYPE_BYTE:
228 printf("byte %d", static_cast< int >(value.m_value.aByte));
229 break;
231 case RT_TYPE_INT16:
232 printf("short %d", static_cast< int >(value.m_value.aShort));
233 break;
235 case RT_TYPE_UINT16:
236 printf(
237 "unsigned short %u",
238 static_cast< unsigned int >(value.m_value.aUShort));
239 break;
241 case RT_TYPE_INT32:
242 printf("long %ld", static_cast< long >(value.m_value.aLong));
243 break;
245 case RT_TYPE_UINT32:
246 printf(
247 "unsigned long %lu",
248 static_cast< unsigned long >(value.m_value.aULong));
249 break;
251 case RT_TYPE_INT64:
252 // TODO: no portable way to print hyper values
253 printf("hyper");
254 break;
256 case RT_TYPE_UINT64:
257 // TODO: no portable way to print unsigned hyper values
258 printf("unsigned hyper");
259 break;
261 case RT_TYPE_FLOAT:
262 // TODO: no portable way to print float values
263 printf("float");
264 break;
266 case RT_TYPE_DOUBLE:
267 // TODO: no portable way to print double values
268 printf("double");
269 break;
271 case RT_TYPE_STRING:
272 printf("string ");
273 printString(value.m_value.aString);
274 break;
276 default:
277 printf("<invalid (%ld)>", static_cast< long >(value.m_type));
278 break;
280 printf("\n");
282 printf(
283 "%smethod count: %u\n", indent.getStr(),
284 static_cast< unsigned int >(reader.getMethodCount()));
285 for (sal_uInt16 i = 0; i < reader.getMethodCount(); ++i) {
286 printf(
287 "%smethod %u:\n", indent.getStr(),
288 static_cast< unsigned int >(i));
289 printf("%s documentation: ", indent.getStr());
290 printString(reader.getMethodDocumentation(i));
291 printf("\n");
292 printf("%s flags: ", indent.getStr());
293 switch (reader.getMethodFlags(i)) {
294 case RTMethodMode::ONEWAY:
295 printf("oneway");
296 break;
298 case RTMethodMode::TWOWAY:
299 printf("synchronous");
300 break;
302 case RTMethodMode::ATTRIBUTE_GET:
303 printf("attribute get");
304 break;
306 case RTMethodMode::ATTRIBUTE_SET:
307 printf("attribute set");
308 break;
310 default:
311 printf(
312 "<invalid (%ld)>",
313 static_cast< long >(reader.getMethodFlags(i)));
314 break;
316 printf("\n");
317 printf("%s name: ", indent.getStr());
318 printString(reader.getMethodName(i));
319 printf("\n");
320 printf("%s return type name: ", indent.getStr());
321 printString(reader.getMethodReturnTypeName(i));
322 printf("\n");
323 printf(
324 "%s parameter count: %u\n", indent.getStr(),
325 static_cast< unsigned int >(reader.getMethodParameterCount(i)));
326 // coverity[tainted_data] - cid#1215304 unhelpfully warns about untrusted loop bound
327 for (sal_uInt16 j = 0; j < reader.getMethodParameterCount(i); ++j)
329 printf(
330 "%s parameter %u:\n", indent.getStr(),
331 static_cast< unsigned int >(j));
332 printf("%s flags: ", indent.getStr());
333 RTParamMode flags = reader.getMethodParameterFlags(i, j);
334 bool rest = (flags & RT_PARAM_REST) != 0;
335 switch (flags & ~RT_PARAM_REST) {
336 case RT_PARAM_IN:
337 printf("in");
338 break;
340 case RT_PARAM_OUT:
341 printf("out");
342 break;
344 case RT_PARAM_INOUT:
345 printf("inout");
346 break;
348 default:
349 printf("<invalid (%ld)>", static_cast< long >(flags));
350 rest = false;
351 break;
353 if (rest) {
354 printf("|rest");
356 printf("\n");
357 printf("%s name: ", indent.getStr());
358 printString(reader.getMethodParameterName(i, j));
359 printf("\n");
360 printf("%s type name: ", indent.getStr());
361 printString(reader.getMethodParameterTypeName(i, j));
362 printf("\n");
364 printf(
365 "%s exception count: %u\n", indent.getStr(),
366 static_cast< unsigned int >(reader.getMethodExceptionCount(i)));
367 // coverity[tainted_data] - cid#1215304 unhelpfully warns about untrusted loop bound
368 for (sal_uInt16 j = 0; j < reader.getMethodExceptionCount(i); ++j)
370 printf(
371 "%s exception type name %u: ", indent.getStr(),
372 static_cast< unsigned int >(j));
373 printString(reader.getMethodExceptionTypeName(i, j));
374 printf("\n");
377 printf(
378 "%sreference count: %u\n", indent.getStr(),
379 static_cast< unsigned int >(reader.getReferenceCount()));
380 for (sal_uInt16 i = 0; i < reader.getReferenceCount(); ++i) {
381 printf(
382 "%sreference %u:\n", indent.getStr(),
383 static_cast< unsigned int >(i));
384 printf("%s documentation: ", indent.getStr());
385 printString(reader.getReferenceDocumentation(i));
386 printf("\n");
387 printf("%s flags: ", indent.getStr());
388 printFieldOrReferenceFlags(reader.getReferenceFlags(i));
389 printf("\n");
390 printf("%s sort: ", indent.getStr());
391 switch (reader.getReferenceSort(i)) {
392 case RTReferenceType::SUPPORTS:
393 printf("supports");
394 break;
396 case RTReferenceType::EXPORTS:
397 printf("exports");
398 break;
400 case RTReferenceType::TYPE_PARAMETER:
401 printf("type parameter");
402 break;
404 default:
405 printf(
406 "<invalid (%ld)>",
407 static_cast< long >(reader.getReferenceSort(i)));
408 break;
410 printf("\n");
411 printf("%s type name: ", indent.getStr());
412 printString(reader.getReferenceTypeName(i));
413 printf("\n");
415 } else {
416 printf("<invalid>\n");
422 ORegistry::ORegistry()
423 : m_refCount(1)
424 , m_readOnly(false)
425 , m_isOpen(false)
429 ORegistry::~ORegistry()
431 ORegKey* pRootKey = m_openKeyTable[ROOT];
432 if (pRootKey != nullptr)
433 (void) releaseKey(pRootKey);
435 if (m_file.isValid())
436 m_file.close();
439 RegError ORegistry::initRegistry(const OUString& regName, RegAccessMode accessMode, bool bCreate)
441 RegError eRet = RegError::INVALID_REGISTRY;
442 OStoreFile rRegFile;
443 storeAccessMode sAccessMode = storeAccessMode::ReadWrite;
444 storeError errCode;
446 if (bCreate)
448 sAccessMode = storeAccessMode::Create;
450 else if (accessMode & RegAccessMode::READONLY)
452 sAccessMode = storeAccessMode::ReadOnly;
453 m_readOnly = true;
456 if (regName.isEmpty() &&
457 storeAccessMode::Create == sAccessMode)
459 errCode = rRegFile.createInMemory();
461 else
463 errCode = rRegFile.create(regName, sAccessMode);
466 if (errCode)
468 switch (errCode)
470 case store_E_NotExists:
471 eRet = RegError::REGISTRY_NOT_EXISTS;
472 break;
473 case store_E_LockingViolation:
474 eRet = RegError::CANNOT_OPEN_FOR_READWRITE;
475 break;
476 default:
477 eRet = RegError::INVALID_REGISTRY;
478 break;
481 else
483 OStoreDirectory rStoreDir;
484 storeError _err = rStoreDir.create(rRegFile, OUString(), OUString(), sAccessMode);
486 if (_err == store_E_None)
488 m_file = rRegFile;
489 m_name = regName;
490 m_isOpen = true;
492 m_openKeyTable[ROOT] = new ORegKey(ROOT, this);
493 eRet = RegError::NO_ERROR;
495 else
496 eRet = RegError::INVALID_REGISTRY;
499 return eRet;
502 RegError ORegistry::closeRegistry()
504 REG_GUARD(m_mutex);
506 if (m_file.isValid())
508 (void) releaseKey(m_openKeyTable[ROOT]);
509 m_file.close();
510 m_isOpen = false;
511 return RegError::NO_ERROR;
512 } else
514 return RegError::REGISTRY_NOT_EXISTS;
518 RegError ORegistry::destroyRegistry(const OUString& regName)
520 REG_GUARD(m_mutex);
522 if (!regName.isEmpty())
524 std::unique_ptr<ORegistry> pReg(new ORegistry());
526 if (pReg->initRegistry(regName, RegAccessMode::READWRITE) == RegError::NO_ERROR)
528 pReg.reset();
530 OUString systemName;
531 if (FileBase::getSystemPathFromFileURL(regName, systemName) != FileBase::E_None)
532 systemName = regName;
534 OString name(OUStringToOString(systemName, osl_getThreadTextEncoding()));
535 if (unlink(name.getStr()) != 0)
537 return RegError::DESTROY_REGISTRY_FAILED;
539 } else
541 return RegError::DESTROY_REGISTRY_FAILED;
543 } else
545 if (m_refCount != 1 || isReadOnly())
547 return RegError::DESTROY_REGISTRY_FAILED;
550 if (m_file.isValid())
552 releaseKey(m_openKeyTable[ROOT]);
553 m_file.close();
554 m_isOpen = false;
556 if (!m_name.isEmpty())
558 OUString systemName;
559 if (FileBase::getSystemPathFromFileURL(m_name, systemName) != FileBase::E_None)
560 systemName = m_name;
562 OString name(OUStringToOString(systemName, osl_getThreadTextEncoding()));
563 if (unlink(name.getStr()) != 0)
565 return RegError::DESTROY_REGISTRY_FAILED;
568 } else
570 return RegError::REGISTRY_NOT_EXISTS;
574 return RegError::NO_ERROR;
577 RegError ORegistry::acquireKey (RegKeyHandle hKey)
579 ORegKey* pKey = static_cast< ORegKey* >(hKey);
580 if (!pKey)
581 return RegError::INVALID_KEY;
583 REG_GUARD(m_mutex);
584 pKey->acquire();
586 return RegError::NO_ERROR;
589 RegError ORegistry::releaseKey (RegKeyHandle hKey)
591 ORegKey* pKey = static_cast< ORegKey* >(hKey);
592 if (!pKey)
593 return RegError::INVALID_KEY;
595 REG_GUARD(m_mutex);
596 if (pKey->release() == 0)
598 m_openKeyTable.erase(pKey->getName());
599 delete pKey;
601 return RegError::NO_ERROR;
604 RegError ORegistry::createKey(RegKeyHandle hKey, const OUString& keyName,
605 RegKeyHandle* phNewKey)
607 ORegKey* pKey;
609 *phNewKey = nullptr;
611 if (keyName.isEmpty())
612 return RegError::INVALID_KEYNAME;
614 REG_GUARD(m_mutex);
616 if (hKey)
617 pKey = static_cast<ORegKey*>(hKey);
618 else
619 pKey = m_openKeyTable[ROOT];
621 OUString sFullKeyName = pKey->getFullPath(keyName);
623 if (m_openKeyTable.count(sFullKeyName) > 0)
625 *phNewKey = m_openKeyTable[sFullKeyName];
626 static_cast<ORegKey*>(*phNewKey)->acquire();
627 static_cast<ORegKey*>(*phNewKey)->setDeleted(false);
628 return RegError::NO_ERROR;
631 OStoreDirectory rStoreDir;
632 OUStringBuffer sFullPath(sFullKeyName.getLength());
633 OUString token;
635 sFullPath.append('/');
637 sal_Int32 nIndex = 0;
640 token = sFullKeyName.getToken(0, '/', nIndex);
641 if (!token.isEmpty())
643 if (rStoreDir.create(pKey->getStoreFile(), sFullPath.getStr(), token, storeAccessMode::Create))
645 return RegError::CREATE_KEY_FAILED;
648 sFullPath.append(token);
649 sFullPath.append('/');
651 } while(nIndex != -1);
654 pKey = new ORegKey(sFullKeyName, this);
655 *phNewKey = pKey;
656 m_openKeyTable[sFullKeyName] = pKey;
658 return RegError::NO_ERROR;
661 RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName,
662 RegKeyHandle* phOpenKey)
664 ORegKey* pKey;
666 *phOpenKey = nullptr;
668 if (keyName.isEmpty())
670 return RegError::INVALID_KEYNAME;
673 REG_GUARD(m_mutex);
675 if (hKey)
676 pKey = static_cast<ORegKey*>(hKey);
677 else
678 pKey = m_openKeyTable[ROOT];
680 OUString path(pKey->getFullPath(keyName));
681 KeyMap::iterator i(m_openKeyTable.find(path));
682 if (i == m_openKeyTable.end()) {
683 sal_Int32 n = path.lastIndexOf('/') + 1;
684 switch (OStoreDirectory().create(
685 pKey->getStoreFile(), path.copy(0, n), path.copy(n),
686 isReadOnly() ? storeAccessMode::ReadOnly : storeAccessMode::ReadWrite))
688 case store_E_NotExists:
689 return RegError::KEY_NOT_EXISTS;
690 case store_E_WrongFormat:
691 return RegError::INVALID_KEY;
692 default:
693 break;
696 std::unique_ptr< ORegKey > p(new ORegKey(path, this));
697 i = m_openKeyTable.insert(std::make_pair(path, p.get())).first;
698 p.release();
699 } else {
700 i->second->acquire();
702 *phOpenKey = i->second;
703 return RegError::NO_ERROR;
706 RegError ORegistry::closeKey(RegKeyHandle hKey)
708 ORegKey* pKey = static_cast< ORegKey* >(hKey);
710 REG_GUARD(m_mutex);
712 OUString const aKeyName (pKey->getName());
713 if (m_openKeyTable.count(aKeyName) <= 0)
714 return RegError::KEY_NOT_OPEN;
716 if (pKey->isModified())
718 ORegKey * pRootKey = getRootKey();
719 if (pKey != pRootKey)
721 // propagate "modified" state to RootKey.
722 pRootKey->setModified();
724 else
726 // closing modified RootKey, flush registry file.
727 (void) m_file.flush();
729 pKey->setModified(false);
730 (void) releaseKey(pRootKey);
733 return releaseKey(pKey);
736 RegError ORegistry::deleteKey(RegKeyHandle hKey, const OUString& keyName)
738 ORegKey* pKey = static_cast< ORegKey* >(hKey);
739 if (keyName.isEmpty())
740 return RegError::INVALID_KEYNAME;
742 REG_GUARD(m_mutex);
744 if (!pKey)
745 pKey = m_openKeyTable[ROOT];
747 OUString sFullKeyName(pKey->getFullPath(keyName));
748 return eraseKey(m_openKeyTable[ROOT], sFullKeyName);
751 RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName)
753 RegError _ret = RegError::NO_ERROR;
755 if (keyName.isEmpty())
757 return RegError::INVALID_KEYNAME;
760 OUString sFullKeyName(pKey->getName());
761 OUString sFullPath(sFullKeyName);
762 OUString sRelativKey;
763 sal_Int32 lastIndex = keyName.lastIndexOf('/');
765 if (lastIndex >= 0)
767 sRelativKey += keyName.copy(lastIndex + 1);
769 if (sFullKeyName.getLength() > 1)
770 sFullKeyName += keyName;
771 else
772 sFullKeyName += keyName.copy(1);
774 sFullPath = sFullKeyName.copy(0, keyName.lastIndexOf('/') + 1);
775 } else
777 if (sFullKeyName.getLength() > 1)
778 sFullKeyName += ROOT;
780 sRelativKey += keyName;
781 sFullKeyName += keyName;
783 if (sFullPath.getLength() > 1)
784 sFullPath += ROOT;
787 ORegKey* pOldKey = nullptr;
788 _ret = pKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pOldKey));
789 if (_ret != RegError::NO_ERROR)
790 return _ret;
792 _ret = deleteSubkeysAndValues(pOldKey);
793 if (_ret != RegError::NO_ERROR)
795 pKey->closeKey(pOldKey);
796 return _ret;
799 OUString tmpName(sRelativKey);
800 tmpName += ROOT;
802 OStoreFile sFile(pKey->getStoreFile());
803 if (sFile.isValid() && sFile.remove(sFullPath, tmpName))
805 return RegError::DELETE_KEY_FAILED;
807 pOldKey->setModified();
809 // set flag deleted !!!
810 pOldKey->setDeleted(true);
812 return pKey->closeKey(pOldKey);
815 RegError ORegistry::deleteSubkeysAndValues(ORegKey* pKey)
817 OStoreDirectory::iterator iter;
818 RegError _ret = RegError::NO_ERROR;
819 OStoreDirectory rStoreDir(pKey->getStoreDir());
820 storeError _err = rStoreDir.first(iter);
822 while (_err == store_E_None)
824 OUString const keyName = iter.m_pszName;
826 if (iter.m_nAttrib & STORE_ATTRIB_ISDIR)
828 _ret = eraseKey(pKey, keyName);
829 if (_ret != RegError::NO_ERROR)
830 return _ret;
832 else
834 OUString sFullPath(pKey->getName());
836 if (sFullPath.getLength() > 1)
837 sFullPath += ROOT;
839 if (const_cast<OStoreFile&>(pKey->getStoreFile()).remove(sFullPath, keyName))
841 return RegError::DELETE_VALUE_FAILED;
843 pKey->setModified();
846 _err = rStoreDir.next(iter);
849 return RegError::NO_ERROR;
852 RegError ORegistry::loadKey(RegKeyHandle hKey, const OUString& regFileName,
853 bool bWarnings, bool bReport)
855 ORegKey* pKey = static_cast< ORegKey* >(hKey);
857 std::unique_ptr< ORegistry > pReg (new ORegistry());
858 RegError _ret = pReg->initRegistry(regFileName, RegAccessMode::READONLY);
859 if (_ret != RegError::NO_ERROR)
860 return _ret;
861 ORegKey* pRootKey = pReg->getRootKey();
863 REG_GUARD(m_mutex);
865 OStoreDirectory::iterator iter;
866 OStoreDirectory rStoreDir(pRootKey->getStoreDir());
867 storeError _err = rStoreDir.first(iter);
869 while (_err == store_E_None)
871 OUString const keyName = iter.m_pszName;
873 if (iter.m_nAttrib & STORE_ATTRIB_ISDIR)
875 _ret = loadAndSaveKeys(pKey, pRootKey, keyName, 0, bWarnings, bReport);
877 else
879 _ret = loadAndSaveValue(pKey, pRootKey, keyName, 0, bWarnings, bReport);
882 if (_ret == RegError::MERGE_ERROR)
883 break;
884 if (_ret == RegError::MERGE_CONFLICT && bWarnings)
885 break;
887 _err = rStoreDir.next(iter);
890 rStoreDir = OStoreDirectory();
891 (void) pReg->releaseKey(pRootKey);
892 return _ret;
895 RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
896 ORegKey const * pSourceKey,
897 const OUString& valueName,
898 sal_uInt32 nCut,
899 bool bWarnings,
900 bool bReport)
902 OStoreStream rValue;
903 RegValueType valueType;
904 sal_uInt32 valueSize;
905 sal_uInt32 nSize;
906 storeAccessMode sourceAccess = storeAccessMode::ReadWrite;
907 OUString sTargetPath(pTargetKey->getName());
908 OUString sSourcePath(pSourceKey->getName());
910 if (pSourceKey->isReadOnly())
912 sourceAccess = storeAccessMode::ReadOnly;
915 if (nCut)
917 sTargetPath = sSourcePath.copy(nCut);
918 } else
920 if (sTargetPath.getLength() > 1)
922 if (sSourcePath.getLength() > 1)
923 sTargetPath += sSourcePath;
924 } else
925 sTargetPath = sSourcePath;
928 if (sTargetPath.getLength() > 1) sTargetPath += ROOT;
929 if (sSourcePath.getLength() > 1) sSourcePath += ROOT;
931 if (rValue.create(pSourceKey->getStoreFile(), sSourcePath, valueName, sourceAccess))
933 return RegError::VALUE_NOT_EXISTS;
936 std::vector<sal_uInt8> aBuffer(VALUE_HEADERSIZE);
938 sal_uInt32 rwBytes;
939 if (rValue.readAt(0, aBuffer.data(), VALUE_HEADERSIZE, rwBytes))
941 return RegError::INVALID_VALUE;
943 if (rwBytes != VALUE_HEADERSIZE)
945 return RegError::INVALID_VALUE;
948 RegError _ret = RegError::NO_ERROR;
949 sal_uInt8 type = aBuffer[0];
950 valueType = static_cast<RegValueType>(type);
951 readUINT32(aBuffer.data() + VALUE_TYPEOFFSET, valueSize);
953 nSize = VALUE_HEADERSIZE + valueSize;
954 aBuffer.resize(nSize);
956 if (rValue.readAt(0, aBuffer.data(), nSize, rwBytes))
958 return RegError::INVALID_VALUE;
960 if (rwBytes != nSize)
962 return RegError::INVALID_VALUE;
965 OStoreFile rTargetFile(pTargetKey->getStoreFile());
967 if (!rValue.create(rTargetFile, sTargetPath, valueName, storeAccessMode::ReadWrite))
969 if (valueType == RegValueType::BINARY)
971 _ret = checkBlop(
972 rValue, sTargetPath, valueSize, aBuffer.data() + VALUE_HEADEROFFSET,
973 bReport);
974 if (_ret != RegError::NO_ERROR)
976 if (_ret == RegError::MERGE_ERROR ||
977 (_ret == RegError::MERGE_CONFLICT && bWarnings))
979 return _ret;
981 } else
983 return _ret;
988 if (rValue.create(rTargetFile, sTargetPath, valueName, storeAccessMode::Create))
990 return RegError::INVALID_VALUE;
992 if (rValue.writeAt(0, aBuffer.data(), nSize, rwBytes))
994 return RegError::INVALID_VALUE;
997 if (rwBytes != nSize)
999 return RegError::INVALID_VALUE;
1001 pTargetKey->setModified();
1003 return _ret;
1006 RegError ORegistry::checkBlop(OStoreStream& rValue,
1007 const OUString& sTargetPath,
1008 sal_uInt32 srcValueSize,
1009 sal_uInt8 const * pSrcBuffer,
1010 bool bReport)
1012 RegistryTypeReader reader(pSrcBuffer, srcValueSize);
1014 if (reader.getTypeClass() == RT_TYPE_INVALID)
1016 return RegError::INVALID_VALUE;
1019 std::vector<sal_uInt8> aBuffer(VALUE_HEADERSIZE);
1020 RegValueType valueType;
1021 sal_uInt32 valueSize;
1022 sal_uInt32 rwBytes;
1023 OString targetPath(OUStringToOString(sTargetPath, RTL_TEXTENCODING_UTF8));
1025 if (!rValue.readAt(0, aBuffer.data(), VALUE_HEADERSIZE, rwBytes) &&
1026 (rwBytes == VALUE_HEADERSIZE))
1028 sal_uInt8 type = aBuffer[0];
1029 valueType = static_cast<RegValueType>(type);
1030 readUINT32(aBuffer.data() + VALUE_TYPEOFFSET, valueSize);
1032 if (valueType == RegValueType::BINARY)
1034 aBuffer.resize(valueSize);
1035 if (!rValue.readAt(VALUE_HEADEROFFSET, aBuffer.data(), valueSize, rwBytes) &&
1036 (rwBytes == valueSize))
1038 RegistryTypeReader reader2(aBuffer.data(), valueSize);
1040 if ((reader.getTypeClass() != reader2.getTypeClass())
1041 || reader2.getTypeClass() == RT_TYPE_INVALID)
1043 if (bReport)
1045 fprintf(stdout, "ERROR: values of blop from key \"%s\" has different types.\n",
1046 targetPath.getStr());
1048 return RegError::MERGE_ERROR;
1051 if (reader.getTypeClass() == RT_TYPE_MODULE)
1053 if (reader.getFieldCount() > 0 &&
1054 reader2.getFieldCount() > 0)
1056 mergeModuleValue(rValue, reader, reader2);
1058 return RegError::NO_ERROR;
1059 } else
1060 if (reader2.getFieldCount() > 0)
1062 return RegError::NO_ERROR;
1063 } else
1065 return RegError::MERGE_CONFLICT;
1067 } else
1069 if (bReport)
1071 fprintf(stderr, "WARNING: value of key \"%s\" already exists.\n",
1072 targetPath.getStr());
1074 return RegError::MERGE_CONFLICT;
1076 } else
1078 if (bReport)
1080 fprintf(stderr, "ERROR: values of key \"%s\" contains bad data.\n",
1081 targetPath.getStr());
1083 return RegError::MERGE_ERROR;
1085 } else
1087 if (bReport)
1089 fprintf(stderr, "ERROR: values of key \"%s\" has different types.\n",
1090 targetPath.getStr());
1092 return RegError::MERGE_ERROR;
1094 } else
1096 return RegError::INVALID_VALUE;
1100 static sal_uInt32 checkTypeReaders(RegistryTypeReader const & reader1,
1101 RegistryTypeReader const & reader2,
1102 std::set< OUString >& nameSet)
1104 sal_uInt32 count=0;
1105 for (sal_uInt32 i=0 ; i < reader1.getFieldCount(); i++)
1107 nameSet.insert(reader1.getFieldName(i));
1108 count++;
1110 for (sal_uInt32 i=0 ; i < reader2.getFieldCount(); i++)
1112 if (nameSet.insert(reader2.getFieldName(i)).second)
1113 count++;
1115 return count;
1118 RegError ORegistry::mergeModuleValue(OStoreStream& rTargetValue,
1119 RegistryTypeReader const & reader,
1120 RegistryTypeReader const & reader2)
1122 std::set< OUString > nameSet;
1123 sal_uInt32 count = checkTypeReaders(reader, reader2, nameSet);
1125 if (count != reader.getFieldCount())
1127 sal_uInt16 index = 0;
1129 RegistryTypeWriter writer(reader.getTypeClass(),
1130 reader.getTypeName(),
1131 reader.getSuperTypeName(),
1132 static_cast<sal_uInt16>(count));
1134 for (sal_uInt32 i=0 ; i < reader.getFieldCount(); i++)
1136 writer.setFieldData(index,
1137 reader.getFieldName(i),
1138 reader.getFieldType(i),
1139 reader.getFieldDoku(i),
1140 reader.getFieldFileName(i),
1141 reader.getFieldAccess(i),
1142 reader.getFieldConstValue(i));
1143 index++;
1145 for (sal_uInt32 i=0 ; i < reader2.getFieldCount(); i++)
1147 if (nameSet.find(reader2.getFieldName(i)) == nameSet.end())
1149 writer.setFieldData(index,
1150 reader2.getFieldName(i),
1151 reader2.getFieldType(i),
1152 reader2.getFieldDoku(i),
1153 reader2.getFieldFileName(i),
1154 reader2.getFieldAccess(i),
1155 reader2.getFieldConstValue(i));
1156 index++;
1160 const sal_uInt8* pBlop = writer.getBlop();
1161 sal_uInt32 aBlopSize = writer.getBlopSize();
1163 sal_uInt8 type = sal_uInt8(RegValueType::BINARY);
1164 std::vector<sal_uInt8> aBuffer(VALUE_HEADERSIZE + aBlopSize);
1166 memcpy(aBuffer.data(), &type, 1);
1167 writeUINT32(aBuffer.data() + VALUE_TYPEOFFSET, aBlopSize);
1168 memcpy(aBuffer.data() + VALUE_HEADEROFFSET, pBlop, aBlopSize);
1170 sal_uInt32 rwBytes;
1171 if (rTargetValue.writeAt(0, aBuffer.data(), VALUE_HEADERSIZE+aBlopSize, rwBytes))
1173 return RegError::INVALID_VALUE;
1176 if (rwBytes != VALUE_HEADERSIZE+aBlopSize)
1178 return RegError::INVALID_VALUE;
1181 return RegError::NO_ERROR;
1184 RegError ORegistry::loadAndSaveKeys(ORegKey* pTargetKey,
1185 ORegKey* pSourceKey,
1186 const OUString& keyName,
1187 sal_uInt32 nCut,
1188 bool bWarnings,
1189 bool bReport)
1191 RegError _ret = RegError::NO_ERROR;
1192 OUString sRelPath(pSourceKey->getName().copy(nCut));
1193 OUString sFullPath;
1195 if(pTargetKey->getName().getLength() > 1)
1196 sFullPath += pTargetKey->getName();
1197 sFullPath += sRelPath;
1198 if (sRelPath.getLength() > 1 || sFullPath.isEmpty())
1199 sFullPath += ROOT;
1201 OUString sFullKeyName = sFullPath;
1202 sFullKeyName += keyName;
1204 OStoreDirectory rStoreDir;
1205 if (rStoreDir.create(pTargetKey->getStoreFile(), sFullPath, keyName, storeAccessMode::Create))
1207 return RegError::CREATE_KEY_FAILED;
1210 if (m_openKeyTable.count(sFullKeyName) > 0)
1212 m_openKeyTable[sFullKeyName]->setDeleted(false);
1215 ORegKey* pTmpKey = nullptr;
1216 _ret = pSourceKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pTmpKey));
1217 if (_ret != RegError::NO_ERROR)
1218 return _ret;
1220 OStoreDirectory::iterator iter;
1221 OStoreDirectory rTmpStoreDir(pTmpKey->getStoreDir());
1222 storeError _err = rTmpStoreDir.first(iter);
1224 while (_err == store_E_None)
1226 OUString const sName = iter.m_pszName;
1228 if (iter.m_nAttrib & STORE_ATTRIB_ISDIR)
1230 _ret = loadAndSaveKeys(pTargetKey, pTmpKey,
1231 sName, nCut, bWarnings, bReport);
1232 } else
1234 _ret = loadAndSaveValue(pTargetKey, pTmpKey,
1235 sName, nCut, bWarnings, bReport);
1238 if (_ret == RegError::MERGE_ERROR)
1239 break;
1240 if (_ret == RegError::MERGE_CONFLICT && bWarnings)
1241 break;
1243 _err = rTmpStoreDir.next(iter);
1246 pSourceKey->releaseKey(pTmpKey);
1247 return _ret;
1250 ORegKey* ORegistry::getRootKey()
1252 m_openKeyTable[ROOT]->acquire();
1253 return m_openKeyTable[ROOT];
1256 RegError ORegistry::dumpRegistry(RegKeyHandle hKey) const
1258 ORegKey *pKey = static_cast<ORegKey*>(hKey);
1259 OUString sName;
1260 RegError _ret = RegError::NO_ERROR;
1261 OStoreDirectory::iterator iter;
1262 OStoreDirectory rStoreDir(pKey->getStoreDir());
1263 storeError _err = rStoreDir.first(iter);
1265 OString regName(OUStringToOString(getName(), osl_getThreadTextEncoding()));
1266 OString keyName(OUStringToOString(pKey->getName(), RTL_TEXTENCODING_UTF8));
1267 fprintf(stdout, "Registry \"%s\":\n\n%s\n", regName.getStr(), keyName.getStr());
1269 while (_err == store_E_None)
1271 sName = iter.m_pszName;
1273 if (iter.m_nAttrib & STORE_ATTRIB_ISDIR)
1275 _ret = dumpKey(pKey->getName(), sName, 1);
1276 } else
1278 _ret = dumpValue(pKey->getName(), sName, 1);
1281 if (_ret != RegError::NO_ERROR)
1283 return _ret;
1286 _err = rStoreDir.next(iter);
1289 return RegError::NO_ERROR;
1292 RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_Int16 nSpc) const
1294 OStoreStream rValue;
1295 sal_uInt32 valueSize;
1296 RegValueType valueType;
1297 OUString sFullPath(sPath);
1298 OString sIndent;
1299 storeAccessMode accessMode = storeAccessMode::ReadWrite;
1301 if (isReadOnly())
1303 accessMode = storeAccessMode::ReadOnly;
1306 for (int i= 0; i < nSpc; i++) sIndent += " ";
1308 if (sFullPath.getLength() > 1)
1310 sFullPath += ROOT;
1312 if (rValue.create(m_file, sFullPath, sName, accessMode))
1314 return RegError::VALUE_NOT_EXISTS;
1317 std::vector<sal_uInt8> aBuffer(VALUE_HEADERSIZE);
1319 sal_uInt32 rwBytes;
1320 if (rValue.readAt(0, aBuffer.data(), VALUE_HEADERSIZE, rwBytes))
1322 return RegError::INVALID_VALUE;
1324 if (rwBytes != (VALUE_HEADERSIZE))
1326 return RegError::INVALID_VALUE;
1329 sal_uInt8 type = aBuffer[0];
1330 valueType = static_cast<RegValueType>(type);
1331 readUINT32(aBuffer.data() + VALUE_TYPEOFFSET, valueSize);
1333 aBuffer.resize(valueSize);
1334 if (rValue.readAt(VALUE_HEADEROFFSET, aBuffer.data(), valueSize, rwBytes))
1336 return RegError::INVALID_VALUE;
1338 if (rwBytes != valueSize)
1340 return RegError::INVALID_VALUE;
1343 const sal_Char* indent = sIndent.getStr();
1344 switch (valueType)
1346 case RegValueType::NOT_DEFINED:
1347 fprintf(stdout, "%sValue: Type = VALUETYPE_NOT_DEFINED\n", indent);
1348 break;
1349 case RegValueType::LONG:
1351 fprintf(stdout, "%sValue: Type = RegValueType::LONG\n", indent);
1352 fprintf(
1353 stdout, "%s Size = %lu\n", indent,
1354 sal::static_int_cast< unsigned long >(valueSize));
1355 fprintf(stdout, "%s Data = ", indent);
1357 sal_Int32 value;
1358 readINT32(aBuffer.data(), value);
1359 fprintf(stdout, "%ld\n", sal::static_int_cast< long >(value));
1361 break;
1362 case RegValueType::STRING:
1364 sal_Char* value = static_cast<sal_Char*>(std::malloc(valueSize));
1365 readUtf8(aBuffer.data(), value, valueSize);
1366 fprintf(stdout, "%sValue: Type = RegValueType::STRING\n", indent);
1367 fprintf(
1368 stdout, "%s Size = %lu\n", indent,
1369 sal::static_int_cast< unsigned long >(valueSize));
1370 fprintf(stdout, "%s Data = \"%s\"\n", indent, value);
1371 std::free(value);
1373 break;
1374 case RegValueType::UNICODE:
1376 sal_uInt32 size = (valueSize / 2) * sizeof(sal_Unicode);
1377 fprintf(stdout, "%sValue: Type = RegValueType::UNICODE\n", indent);
1378 fprintf(
1379 stdout, "%s Size = %lu\n", indent,
1380 sal::static_int_cast< unsigned long >(valueSize));
1381 fprintf(stdout, "%s Data = ", indent);
1383 std::unique_ptr<sal_Unicode[]> value(new sal_Unicode[size]);
1384 readString(aBuffer.data(), value.get(), size);
1386 OString uStr = OUStringToOString(value.get(), RTL_TEXTENCODING_UTF8);
1387 fprintf(stdout, "L\"%s\"\n", uStr.getStr());
1389 break;
1390 case RegValueType::BINARY:
1392 fprintf(stdout, "%sValue: Type = RegValueType::BINARY\n", indent);
1393 fprintf(
1394 stdout, "%s Size = %lu\n", indent,
1395 sal::static_int_cast< unsigned long >(valueSize));
1396 fprintf(stdout, "%s Data = ", indent);
1397 dumpType(
1398 typereg::Reader(aBuffer.data(), valueSize),
1399 sIndent + " ");
1401 break;
1402 case RegValueType::LONGLIST:
1404 sal_uInt32 offset = 4; // initial 4 bytes for the size of the array
1405 sal_uInt32 len = 0;
1407 readUINT32(aBuffer.data(), len);
1409 fprintf(stdout, "%sValue: Type = RegValueType::LONGLIST\n", indent);
1410 fprintf(
1411 stdout, "%s Size = %lu\n", indent,
1412 sal::static_int_cast< unsigned long >(valueSize));
1413 fprintf(
1414 stdout, "%s Len = %lu\n", indent,
1415 sal::static_int_cast< unsigned long >(len));
1416 fprintf(stdout, "%s Data = ", indent);
1418 sal_Int32 longValue;
1419 for (sal_uInt32 i=0; i < len; i++)
1421 readINT32(aBuffer.data() + offset, longValue);
1423 if (offset > 4)
1424 fprintf(stdout, "%s ", indent);
1426 fprintf(
1427 stdout, "%lu = %ld\n",
1428 sal::static_int_cast< unsigned long >(i),
1429 sal::static_int_cast< long >(longValue));
1430 offset += 4; // 4 Bytes for sal_Int32
1433 break;
1434 case RegValueType::STRINGLIST:
1436 sal_uInt32 offset = 4; // initial 4 bytes for the size of the array
1437 sal_uInt32 sLen = 0;
1438 sal_uInt32 len = 0;
1440 readUINT32(aBuffer.data(), len);
1442 fprintf(stdout, "%sValue: Type = RegValueType::STRINGLIST\n", indent);
1443 fprintf(
1444 stdout, "%s Size = %lu\n", indent,
1445 sal::static_int_cast< unsigned long >(valueSize));
1446 fprintf(
1447 stdout, "%s Len = %lu\n", indent,
1448 sal::static_int_cast< unsigned long >(len));
1449 fprintf(stdout, "%s Data = ", indent);
1451 for (sal_uInt32 i=0; i < len; i++)
1453 readUINT32(aBuffer.data() + offset, sLen);
1455 offset += 4; // 4 bytes (sal_uInt32) for the string size
1457 sal_Char *pValue = static_cast<sal_Char*>(std::malloc(sLen));
1458 readUtf8(aBuffer.data() + offset, pValue, sLen);
1460 if (offset > 8)
1461 fprintf(stdout, "%s ", indent);
1463 fprintf(
1464 stdout, "%lu = \"%s\"\n",
1465 sal::static_int_cast< unsigned long >(i), pValue);
1466 std::free(pValue);
1467 offset += sLen;
1470 break;
1471 case RegValueType::UNICODELIST:
1473 sal_uInt32 offset = 4; // initial 4 bytes for the size of the array
1474 sal_uInt32 sLen = 0;
1475 sal_uInt32 len = 0;
1477 readUINT32(aBuffer.data(), len);
1479 fprintf(stdout, "%sValue: Type = RegValueType::UNICODELIST\n", indent);
1480 fprintf(
1481 stdout, "%s Size = %lu\n", indent,
1482 sal::static_int_cast< unsigned long >(valueSize));
1483 fprintf(
1484 stdout, "%s Len = %lu\n", indent,
1485 sal::static_int_cast< unsigned long >(len));
1486 fprintf(stdout, "%s Data = ", indent);
1488 OString uStr;
1489 for (sal_uInt32 i=0; i < len; i++)
1491 readUINT32(aBuffer.data() + offset, sLen);
1493 offset += 4; // 4 bytes (sal_uInt32) for the string size
1495 sal_Unicode *pValue = static_cast<sal_Unicode*>(std::malloc((sLen / 2) * sizeof(sal_Unicode)));
1496 readString(aBuffer.data() + offset, pValue, sLen);
1498 if (offset > 8)
1499 fprintf(stdout, "%s ", indent);
1501 uStr = OUStringToOString(pValue, RTL_TEXTENCODING_UTF8);
1502 fprintf(
1503 stdout, "%lu = L\"%s\"\n",
1504 sal::static_int_cast< unsigned long >(i),
1505 uStr.getStr());
1507 offset += sLen;
1509 std::free(pValue);
1512 break;
1515 fprintf(stdout, "\n");
1517 return RegError::NO_ERROR;
1520 RegError ORegistry::dumpKey(const OUString& sPath, const OUString& sName, sal_Int16 nSpace) const
1522 OStoreDirectory rStoreDir;
1523 OUString sFullPath(sPath);
1524 OString sIndent;
1525 storeAccessMode accessMode = storeAccessMode::ReadWrite;
1526 RegError _ret = RegError::NO_ERROR;
1528 if (isReadOnly())
1530 accessMode = storeAccessMode::ReadOnly;
1533 for (int i= 0; i < nSpace; i++) sIndent += " ";
1535 if (sFullPath.getLength() > 1)
1536 sFullPath += ROOT;
1538 storeError _err = rStoreDir.create(m_file, sFullPath, sName, accessMode);
1540 if (_err == store_E_NotExists)
1541 return RegError::KEY_NOT_EXISTS;
1542 else if (_err == store_E_WrongFormat)
1543 return RegError::INVALID_KEY;
1545 fprintf(stdout, "%s/ %s\n", sIndent.getStr(), OUStringToOString(sName, RTL_TEXTENCODING_UTF8).getStr());
1547 OUString sSubPath(sFullPath);
1548 OUString sSubName;
1549 sSubPath += sName;
1551 OStoreDirectory::iterator iter;
1553 _err = rStoreDir.first(iter);
1555 while (_err == store_E_None)
1557 sSubName = iter.m_pszName;
1559 if (iter.m_nAttrib & STORE_ATTRIB_ISDIR)
1561 _ret = dumpKey(sSubPath, sSubName, nSpace+2);
1562 } else
1564 _ret = dumpValue(sSubPath, sSubName, nSpace+2);
1567 if (_ret != RegError::NO_ERROR)
1569 return _ret;
1572 _err = rStoreDir.next(iter);
1575 return RegError::NO_ERROR;
1578 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */