Bug Summary

File:registry/source/regkey.cxx
Location:line 542, column 5
Description:Dereference of null pointer (loaded from variable 'pValueList')

Annotated Source Code

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21#include "regkey.hxx"
22
23#include <registry/registry.hxx>
24#include <rtl/alloc.h>
25#include "regimpl.hxx"
26#include "keyimpl.hxx"
27
28using rtl::OUString;
29
30//*********************************************************************
31// acquireKey
32//
33void REGISTRY_CALLTYPE acquireKey(RegKeyHandle hKey)
34{
35 ORegKey* pKey = static_cast< ORegKey* >(hKey);
36 if (pKey != 0)
37 {
38 ORegistry* pReg = pKey->getRegistry();
39 (void) pReg->acquireKey(pKey);
40 }
41}
42
43
44//*********************************************************************
45// releaseKey
46//
47void REGISTRY_CALLTYPE releaseKey(RegKeyHandle hKey)
48{
49 ORegKey* pKey = static_cast< ORegKey* >(hKey);
50 if (pKey != 0)
51 {
52 ORegistry* pReg = pKey->getRegistry();
53 (void) pReg->releaseKey(pKey);
54 }
55}
56
57
58//*********************************************************************
59// isKeyReadOnly
60//
61sal_Bool REGISTRY_CALLTYPE isKeyReadOnly(RegKeyHandle hKey)
62{
63 ORegKey* pKey = static_cast< ORegKey* >(hKey);
64 return (pKey != 0) ? pKey->isReadOnly() : sal_False((sal_Bool)0);
65}
66
67
68//*********************************************************************
69// getKeyName
70//
71RegError REGISTRY_CALLTYPE getKeyName(RegKeyHandle hKey, rtl_uString** pKeyName)
72{
73 ORegKey* pKey = static_cast< ORegKey* >(hKey);
74 if (pKey)
75 {
76 rtl_uString_assign( pKeyName, pKey->getName().pData );
77 return REG_NO_ERROR;
78 } else
79 {
80 rtl_uString_new(pKeyName);
81 return REG_INVALID_KEY;
82 }
83}
84
85
86//*********************************************************************
87// createKey
88//
89RegError REGISTRY_CALLTYPE createKey(RegKeyHandle hKey,
90 rtl_uString* keyName,
91 RegKeyHandle* phNewKey)
92{
93 *phNewKey = 0;
94
95 ORegKey* pKey = static_cast< ORegKey* >(hKey);
96 if (!pKey)
97 return REG_INVALID_KEY;
98
99 if (pKey->isDeleted())
100 return REG_INVALID_KEY;
101
102 if (pKey->isReadOnly())
103 return REG_REGISTRY_READONLY;
104
105 return pKey->createKey(keyName, phNewKey);
106}
107
108//*********************************************************************
109// openKey
110//
111RegError REGISTRY_CALLTYPE openKey(RegKeyHandle hKey,
112 rtl_uString* keyName,
113 RegKeyHandle* phOpenKey)
114{
115 *phOpenKey = 0;
116
117 ORegKey* pKey = static_cast< ORegKey* >(hKey);
118 if (!pKey)
119 return REG_INVALID_KEY;
120
121 if (pKey->isDeleted())
122 return REG_INVALID_KEY;
123
124 return pKey->openKey(keyName, phOpenKey);
125}
126
127//*********************************************************************
128// openSubKeys
129//
130RegError REGISTRY_CALLTYPE openSubKeys(RegKeyHandle hKey,
131 rtl_uString* keyName,
132 RegKeyHandle** pphSubKeys,
133 sal_uInt32* pnSubKeys)
134{
135 *pphSubKeys = NULL__null;
136 *pnSubKeys = 0;
137
138 ORegKey* pKey = static_cast< ORegKey* >(hKey);
139 if (!pKey)
140 return REG_INVALID_KEY;
141
142 if (pKey->isDeleted())
143 return REG_INVALID_KEY;
144
145 return pKey->openSubKeys(keyName, pphSubKeys, pnSubKeys);
146}
147
148//*********************************************************************
149// closeSubKeys
150//
151RegError REGISTRY_CALLTYPE closeSubKeys(RegKeyHandle* phSubKeys,
152 sal_uInt32 nSubKeys)
153{
154 if (phSubKeys == 0 || nSubKeys == 0)
155 return REG_INVALID_KEY;
156
157 ORegistry* pReg = ((ORegKey*)(phSubKeys[0]))->getRegistry();
158 for (sal_uInt32 i = 0; i < nSubKeys; i++)
159 {
160 (void) pReg->closeKey(phSubKeys[i]);
161 }
162 rtl_freeMemory(phSubKeys);
163
164 return REG_NO_ERROR;
165}
166
167//*********************************************************************
168// deleteKey
169//
170RegError REGISTRY_CALLTYPE deleteKey(RegKeyHandle hKey,
171 rtl_uString* keyName)
172{
173 ORegKey* pKey = static_cast< ORegKey* >(hKey);
174 if (!pKey)
175 return REG_INVALID_KEY;
176
177 if (pKey->isDeleted())
178 return REG_INVALID_KEY;
179
180 if (pKey->isReadOnly())
181 return REG_REGISTRY_READONLY;
182
183 return pKey->deleteKey(keyName);
184}
185
186//*********************************************************************
187// closeKey
188//
189RegError REGISTRY_CALLTYPE closeKey(RegKeyHandle hKey)
190{
191 ORegKey* pKey = static_cast< ORegKey* >(hKey);
192 if (!pKey)
193 return REG_INVALID_KEY;
194
195 return pKey->closeKey(hKey);
196}
197
198//*********************************************************************
199// setValue
200//
201RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey,
202 rtl_uString* keyName,
203 RegValueType valueType,
204 RegValue pData,
205 sal_uInt32 valueSize)
206{
207 ORegKey* pKey = static_cast< ORegKey* >(hKey);
208 if (!pKey)
209 return REG_INVALID_KEY;
210
211 if (pKey->isDeleted())
212 return REG_INVALID_KEY;
213
214 if (pKey->isReadOnly())
215 return REG_REGISTRY_READONLY;
216
217 OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value")(&("value")[0]), ((sal_Int32)((sizeof ("value") / sizeof (
("value")[0]))-1)), (((rtl_TextEncoding) 11))
);
218 if (keyName->length)
219 {
220 ORegKey* pSubKey = 0;
221 RegError _ret1 = pKey->openKey(keyName, (RegKeyHandle*)&pSubKey);
222 if (_ret1 != REG_NO_ERROR)
223 return _ret1;
224
225 _ret1 = pSubKey->setValue(valueName, valueType, pData, valueSize);
226 if (_ret1 != REG_NO_ERROR)
227 {
228 RegError _ret2 = pKey->closeKey(pSubKey);
229 if (_ret2)
230 return _ret2;
231 else
232 return _ret1;
233 }
234
235 return pKey->closeKey(pSubKey);
236 }
237
238 return pKey->setValue(valueName, valueType, pData, valueSize);
239}
240
241//*********************************************************************
242// setLongValueList
243//
244RegError REGISTRY_CALLTYPE setLongListValue(RegKeyHandle hKey,
245 rtl_uString* keyName,
246 sal_Int32* pValueList,
247 sal_uInt32 len)
248{
249 ORegKey* pKey = static_cast< ORegKey* >(hKey);
250 if (!pKey)
251 return REG_INVALID_KEY;
252
253 if (pKey->isDeleted())
254 return REG_INVALID_KEY;
255
256 if (pKey->isReadOnly())
257 return REG_REGISTRY_READONLY;
258
259 OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value")(&("value")[0]), ((sal_Int32)((sizeof ("value") / sizeof (
("value")[0]))-1)), (((rtl_TextEncoding) 11))
);
260 if (keyName->length)
261 {
262 ORegKey* pSubKey = 0;
263 RegError _ret1 = pKey->openKey(keyName, (RegKeyHandle*)&pSubKey);
264 if (_ret1 != REG_NO_ERROR)
265 return _ret1;
266
267 _ret1 = pSubKey->setLongListValue(valueName, pValueList, len);
268 if (_ret1 != REG_NO_ERROR)
269 {
270 RegError _ret2 = pKey->closeKey(pSubKey);
271 if (_ret2 != REG_NO_ERROR)
272 return _ret2;
273 else
274 return _ret1;
275 }
276
277 return pKey->closeKey(pSubKey);
278 }
279
280 return pKey->setLongListValue(valueName, pValueList, len);
281}
282
283//*********************************************************************
284// setStringValueList
285//
286RegError REGISTRY_CALLTYPE setStringListValue(RegKeyHandle hKey,
287 rtl_uString* keyName,
288 sal_Char** pValueList,
289 sal_uInt32 len)
290{
291 ORegKey* pKey = static_cast< ORegKey* >(hKey);
292 if (!pKey)
293 return REG_INVALID_KEY;
294
295 if (pKey->isDeleted())
296 return REG_INVALID_KEY;
297
298 if (pKey->isReadOnly())
299 return REG_REGISTRY_READONLY;
300
301 OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value")(&("value")[0]), ((sal_Int32)((sizeof ("value") / sizeof (
("value")[0]))-1)), (((rtl_TextEncoding) 11))
);
302 if (keyName->length)
303 {
304 ORegKey* pSubKey = 0;
305 RegError _ret1 = pKey->openKey(keyName, (RegKeyHandle*)&pSubKey);
306 if (_ret1 != REG_NO_ERROR)
307 return _ret1;
308
309 _ret1 = pSubKey->setStringListValue(valueName, pValueList, len);
310 if (_ret1 != REG_NO_ERROR)
311 {
312 RegError _ret2 = pKey->closeKey(pSubKey);
313 if (_ret2 != REG_NO_ERROR)
314 return _ret2;
315 else
316 return _ret1;
317 }
318
319 return pKey->closeKey(pSubKey);
320 }
321
322 return pKey->setStringListValue(valueName, pValueList, len);
323}
324
325//*********************************************************************
326// setUnicodeValueList
327//
328RegError REGISTRY_CALLTYPE setUnicodeListValue(RegKeyHandle hKey,
329 rtl_uString* keyName,
330 sal_Unicode** pValueList,
331 sal_uInt32 len)
332{
333 ORegKey* pKey = static_cast< ORegKey* >(hKey);
334 if (!pKey)
335 return REG_INVALID_KEY;
336
337 if (pKey->isDeleted())
338 return REG_INVALID_KEY;
339
340 if (pKey->isReadOnly())
341 return REG_REGISTRY_READONLY;
342
343 OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value")(&("value")[0]), ((sal_Int32)((sizeof ("value") / sizeof (
("value")[0]))-1)), (((rtl_TextEncoding) 11))
);
344 if (keyName->length)
345 {
346 ORegKey* pSubKey = 0;
347 RegError _ret1 = pKey->openKey(keyName, (RegKeyHandle*)&pSubKey);
348 if (_ret1 != REG_NO_ERROR)
349 return _ret1;
350
351 _ret1 = pSubKey->setUnicodeListValue(valueName, pValueList, len);
352 if (_ret1 != REG_NO_ERROR)
353 {
354 RegError _ret2 = pKey->closeKey(pSubKey);
355 if (_ret2 != REG_NO_ERROR)
356 return _ret2;
357 else
358 return _ret1;
359 }
360
361 return pKey->closeKey(pSubKey);
362 }
363
364 return pKey->setUnicodeListValue(valueName, pValueList, len);
365}
366
367//*********************************************************************
368// getValueInfo
369//
370RegError REGISTRY_CALLTYPE getValueInfo(RegKeyHandle hKey,
371 rtl_uString* keyName,
372 RegValueType* pValueType,
373 sal_uInt32* pValueSize)
374{
375 *pValueType = RG_VALUETYPE_NOT_DEFINED;
376 *pValueSize = 0;
377
378 ORegKey* pKey = static_cast< ORegKey* >(hKey);
379 if (!pKey)
380 return REG_INVALID_KEY;
381
382 if (pKey->isDeleted())
383 return REG_INVALID_KEY;
384
385 RegValueType valueType;
386 sal_uInt32 valueSize;
387
388 OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value")(&("value")[0]), ((sal_Int32)((sizeof ("value") / sizeof (
("value")[0]))-1)), (((rtl_TextEncoding) 11))
);
389 if (keyName->length)
390 {
391 ORegKey* pSubKey = 0;
392 RegError _ret = pKey->openKey(keyName, (RegKeyHandle*)&pSubKey);
393 if (_ret != REG_NO_ERROR)
394 return _ret;
395
396 if (pSubKey->getValueInfo(valueName, &valueType, &valueSize) != REG_NO_ERROR)
397 {
398 (void) pKey->releaseKey(pSubKey);
399 return REG_INVALID_VALUE;
400 }
401
402 *pValueType = valueType;
403 *pValueSize = valueSize;
404
405 return pKey->releaseKey(pSubKey);
406 }
407
408
409 if (pKey->getValueInfo(valueName, &valueType, &valueSize) != REG_NO_ERROR)
410 {
411 return REG_INVALID_VALUE;
412 }
413
414 *pValueType = valueType;
415 *pValueSize = valueSize;
416
417 return REG_NO_ERROR;
418}
419
420//*********************************************************************
421// getValueInfo
422//
423RegError REGISTRY_CALLTYPE getValue(RegKeyHandle hKey,
424 rtl_uString* keyName,
425 RegValue pValue)
426{
427 ORegKey* pKey = static_cast< ORegKey* >(hKey);
428 if (!pKey)
429 return REG_INVALID_KEY;
430
431 if (pKey->isDeleted())
432 return REG_INVALID_KEY;
433
434 OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value")(&("value")[0]), ((sal_Int32)((sizeof ("value") / sizeof (
("value")[0]))-1)), (((rtl_TextEncoding) 11))
);
435 if (keyName->length)
436 {
437 ORegKey* pSubKey = 0;
438 RegError _ret1 = pKey->openKey(keyName, (RegKeyHandle*)&pSubKey);
439 if (_ret1 != REG_NO_ERROR)
440 return _ret1;
441
442 _ret1 = pSubKey->getValue(valueName, pValue);
443 if (_ret1 != REG_NO_ERROR)
444 {
445 (void) pKey->releaseKey(pSubKey);
446 return _ret1;
447 }
448
449 return pKey->releaseKey(pSubKey);
450 }
451
452 return pKey->getValue(valueName, pValue);
453}
454
455//*********************************************************************
456// getLongValueList
457//
458RegError REGISTRY_CALLTYPE getLongListValue(RegKeyHandle hKey,
459 rtl_uString* keyName,
460 sal_Int32** pValueList,
461 sal_uInt32* pLen)
462{
463 OSL_PRECOND((pValueList != 0) && (pLen != 0), "registry::getLongListValue(): invalid parameter")do { if (true && (!((pValueList != 0) && (pLen
!= 0)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN),
("legacy.osl"), ("/usr/local/src/libreoffice/registry/source/regkey.cxx"
":" "463" ": "), "%s", "registry::getLongListValue(): invalid parameter"
); } } while (false)
;
464 *pValueList = 0, *pLen = 0;
465
466 ORegKey* pKey = static_cast< ORegKey* >(hKey);
467 if (!pKey)
468 return REG_INVALID_KEY;
469
470 if (pKey->isDeleted())
471 return REG_INVALID_KEY;
472
473 OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value")(&("value")[0]), ((sal_Int32)((sizeof ("value") / sizeof (
("value")[0]))-1)), (((rtl_TextEncoding) 11))
);
474 if (keyName->length)
475 {
476 ORegKey* pSubKey = 0;
477 RegError _ret1 = pKey->openKey(keyName, (RegKeyHandle*)&pSubKey);
478 if (_ret1 != REG_NO_ERROR)
479 return _ret1;
480
481 _ret1 = pSubKey->getLongListValue(valueName, pValueList, pLen);
482 if (_ret1 != REG_NO_ERROR)
483 {
484 (void) pKey->releaseKey(pSubKey);
485 return _ret1;
486 }
487
488 return pKey->releaseKey(pSubKey);
489 }
490
491 return pKey->getLongListValue(valueName, pValueList, pLen);
492}
493
494//*********************************************************************
495// getStringValueList
496//
497RegError REGISTRY_CALLTYPE getStringListValue(RegKeyHandle hKey,
498 rtl_uString* keyName,
499 sal_Char*** pValueList,
500 sal_uInt32* pLen)
501{
502 OSL_PRECOND((pValueList != 0) && (pLen != 0), "registry::getStringListValue(): invalid parameter")do { if (true && (!((pValueList != 0) && (pLen
!= 0)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN),
("legacy.osl"), ("/usr/local/src/libreoffice/registry/source/regkey.cxx"
":" "502" ": "), "%s", "registry::getStringListValue(): invalid parameter"
); } } while (false)
;
503 *pValueList = 0, *pLen = 0;
504
505 ORegKey* pKey = static_cast< ORegKey* >(hKey);
506 if (!pKey)
507 return REG_INVALID_KEY;
508
509 if (pKey->isDeleted())
510 return REG_INVALID_KEY;
511
512 OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value")(&("value")[0]), ((sal_Int32)((sizeof ("value") / sizeof (
("value")[0]))-1)), (((rtl_TextEncoding) 11))
);
513 if (keyName->length)
514 {
515 ORegKey* pSubKey = 0;
516 RegError _ret1 = pKey->openKey(keyName, (RegKeyHandle*)&pSubKey);
517 if (_ret1 != REG_NO_ERROR)
518 return _ret1;
519
520 _ret1 = pSubKey->getStringListValue(valueName, pValueList, pLen);
521 if (_ret1 != REG_NO_ERROR)
522 {
523 (void) pKey->releaseKey(pSubKey);
524 return _ret1;
525 }
526
527 return pKey->releaseKey(pSubKey);
528 }
529
530 return pKey->getStringListValue(valueName, pValueList, pLen);
531}
532
533//*********************************************************************
534// getUnicodeListValue
535//
536RegError REGISTRY_CALLTYPE getUnicodeListValue(RegKeyHandle hKey,
537 rtl_uString* keyName,
538 sal_Unicode*** pValueList,
539 sal_uInt32* pLen)
540{
541 OSL_PRECOND((pValueList != 0) && (pLen != 0), "registry::getUnicodeListValue(): invalid parameter")do { if (true && (!((pValueList != 0) && (pLen
!= 0)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN),
("legacy.osl"), ("/usr/local/src/libreoffice/registry/source/regkey.cxx"
":" "541" ": "), "%s", "registry::getUnicodeListValue(): invalid parameter"
); } } while (false)
;
3
Within the expansion of the macro 'OSL_PRECOND':
a
Assuming 'pValueList' is equal to null
b
Assuming pointer value is null
542 *pValueList = 0, *pLen = 0;
4
Dereference of null pointer (loaded from variable 'pValueList')
543
544 ORegKey* pKey = static_cast< ORegKey* >(hKey);
545 if (!pKey)
546 return REG_INVALID_KEY;
547
548 if (pKey->isDeleted())
549 return REG_INVALID_KEY;
550
551 OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value")(&("value")[0]), ((sal_Int32)((sizeof ("value") / sizeof (
("value")[0]))-1)), (((rtl_TextEncoding) 11))
);
552 if (keyName->length)
553 {
554 ORegKey* pSubKey = 0;
555 RegError _ret1 = pKey->openKey(keyName, (RegKeyHandle*)&pSubKey);
556 if (_ret1 != REG_NO_ERROR)
557 return _ret1;
558
559 _ret1 = pSubKey->getUnicodeListValue(valueName, pValueList, pLen);
560 if (_ret1 != REG_NO_ERROR)
561 {
562 (void) pKey->releaseKey(pSubKey);
563 return _ret1;
564 }
565
566 return pKey->releaseKey(pSubKey);
567 }
568
569 return pKey->getUnicodeListValue(valueName, pValueList, pLen);
570}
571
572//*********************************************************************
573// freeValueList
574//
575RegError REGISTRY_CALLTYPE freeValueList(RegValueType valueType,
576 RegValue pValueList,
577 sal_uInt32 len)
578{
579 switch (valueType)
580 {
581 case 5:
582 {
583 rtl_freeMemory(pValueList);
584 }
585 break;
586 case 6:
587 {
588 sal_Char** pVList = (sal_Char**)pValueList;
589 for (sal_uInt32 i=0; i < len; i++)
590 {
591 rtl_freeMemory(pVList[i]);
592 }
593
594 rtl_freeMemory(pVList);
595 }
596 break;
597 case 7:
598 {
599 sal_Unicode** pVList = (sal_Unicode**)pValueList;
600 for (sal_uInt32 i=0; i < len; i++)
601 {
602 rtl_freeMemory(pVList[i]);
603 }
604
605 rtl_freeMemory(pVList);
606 }
607 break;
608 default:
609 return REG_INVALID_VALUE;
610 }
611
612 pValueList = NULL__null;
613 return REG_NO_ERROR;
614}
615
616//*********************************************************************
617// createLink
618//
619RegError REGISTRY_CALLTYPE createLink(
620 SAL_UNUSED_PARAMETER__attribute__ ((unused)) RegKeyHandle, SAL_UNUSED_PARAMETER__attribute__ ((unused)) rtl_uString*,
621 SAL_UNUSED_PARAMETER__attribute__ ((unused)) rtl_uString*)
622{
623 return REG_INVALID_LINK; // links are no longer supported
624}
625
626//*********************************************************************
627// deleteLink
628//
629RegError REGISTRY_CALLTYPE deleteLink(
630 SAL_UNUSED_PARAMETER__attribute__ ((unused)) RegKeyHandle, SAL_UNUSED_PARAMETER__attribute__ ((unused)) rtl_uString*)
631{
632 return REG_INVALID_LINK; // links are no longer supported
633}
634
635//*********************************************************************
636// getKeyType
637//
638RegError REGISTRY_CALLTYPE getKeyType(RegKeyHandle hKey,
639 rtl_uString* keyName,
640 RegKeyType* pKeyType)
641{
642 ORegKey* pKey = static_cast< ORegKey* >(hKey);
643 if (!pKey)
644 return REG_INVALID_KEY;
645
646 if (pKey->isDeleted())
647 return REG_INVALID_KEY;
648
649 return pKey->getKeyType(keyName, pKeyType);
650}
651
652//*********************************************************************
653// getLinkTarget
654//
655RegError REGISTRY_CALLTYPE getLinkTarget(
656 SAL_UNUSED_PARAMETER__attribute__ ((unused)) RegKeyHandle, SAL_UNUSED_PARAMETER__attribute__ ((unused)) rtl_uString*,
657 SAL_UNUSED_PARAMETER__attribute__ ((unused)) rtl_uString**)
658{
659 return REG_INVALID_LINK; // links are no longer supported
660}
661
662//*********************************************************************
663// getName
664//
665RegError REGISTRY_CALLTYPE getResolvedKeyName(RegKeyHandle hKey,
666 rtl_uString* keyName,
667 SAL_UNUSED_PARAMETER__attribute__ ((unused)) sal_Bool,
668 rtl_uString** pResolvedName)
669{
670 ORegKey* pKey = static_cast< ORegKey* >(hKey);
671 if (!pKey)
672 return REG_INVALID_KEY;
673
674 if (pKey->isDeleted())
675 return REG_INVALID_KEY;
676
677 OUString resolvedName;
678 RegError _ret = pKey->getResolvedKeyName(keyName, resolvedName);
679 if (_ret == REG_NO_ERROR)
680 rtl_uString_assign(pResolvedName, resolvedName.pData);
681 return _ret;
682}
683
684//*********************************************************************
685// getKeyNames
686//
687RegError REGISTRY_CALLTYPE getKeyNames(RegKeyHandle hKey,
688 rtl_uString* keyName,
689 rtl_uString*** pSubKeyNames,
690 sal_uInt32* pnSubKeys)
691{
692 ORegKey* pKey = static_cast< ORegKey* >(hKey);
693 if (!pKey)
694 return REG_INVALID_KEY;
695
696 if (pKey->isDeleted())
697 return REG_INVALID_KEY;
698
699 return pKey->getKeyNames(keyName, pSubKeyNames, pnSubKeys);
700}
701
702//*********************************************************************
703// freeKeyNames
704//
705RegError REGISTRY_CALLTYPE freeKeyNames(rtl_uString** pKeyNames,
706 sal_uInt32 nKeys)
707{
708 for (sal_uInt32 i=0; i < nKeys; i++)
709 {
710 rtl_uString_release(pKeyNames[i]);
711 }
712
713 rtl_freeMemory(pKeyNames);
714
715 return REG_NO_ERROR;
716}
717
718//*********************************************************************
719// C API
720//
721
722//*********************************************************************
723// reg_createKey
724//
725RegError REGISTRY_CALLTYPE reg_createKey(RegKeyHandle hKey,
726 rtl_uString* keyName,
727 RegKeyHandle* phNewKey)
728{
729 if (!hKey)
730 return REG_INVALID_KEY;
731
732 return createKey(hKey, keyName, phNewKey);
733}
734
735//*********************************************************************
736// reg_openKey
737//
738RegError REGISTRY_CALLTYPE reg_openKey(RegKeyHandle hKey,
739 rtl_uString* keyName,
740 RegKeyHandle* phOpenKey)
741{
742 if (!hKey)
743 return REG_INVALID_KEY;
744
745 return openKey(hKey, keyName, phOpenKey);
746}
747
748//*********************************************************************
749// reg_openSubKeys
750//
751RegError REGISTRY_CALLTYPE reg_openSubKeys(RegKeyHandle hKey,
752 rtl_uString* keyName,
753 RegKeyHandle** pphSubKeys,
754 sal_uInt32* pnSubKeys)
755{
756 if (!hKey)
757 return REG_INVALID_KEY;
758
759 return openSubKeys(hKey, keyName, pphSubKeys, pnSubKeys);
760}
761
762//*********************************************************************
763// reg_closeSubKeys
764//
765RegError REGISTRY_CALLTYPE reg_closeSubKeys(RegKeyHandle* pphSubKeys,
766 sal_uInt32 nSubKeys)
767{
768 if (!pphSubKeys)
769 return REG_INVALID_KEY;
770
771 return closeSubKeys(pphSubKeys, nSubKeys);
772}
773
774//*********************************************************************
775// reg_deleteKey
776//
777RegError REGISTRY_CALLTYPE reg_deleteKey(RegKeyHandle hKey,
778 rtl_uString* keyName)
779{
780 if (!hKey)
781 return REG_INVALID_KEY;
782
783 return deleteKey(hKey, keyName);
784}
785
786//*********************************************************************
787// reg_closeKey
788//
789RegError REGISTRY_CALLTYPE reg_closeKey(RegKeyHandle hKey)
790{
791 if (!hKey)
792 return REG_INVALID_KEY;
793
794 return closeKey(hKey);
795}
796
797
798//*********************************************************************
799// reg_getKeyName
800//
801RegError REGISTRY_CALLTYPE reg_getKeyName(RegKeyHandle hKey, rtl_uString** pKeyName)
802{
803 if (hKey)
804 {
805 rtl_uString_assign( pKeyName, ((ORegKey*)hKey)->getName().pData );
806 return REG_NO_ERROR;
807 } else
808 {
809 rtl_uString_new( pKeyName );
810 return REG_INVALID_KEY;
811 }
812}
813
814//*********************************************************************
815// reg_setValue
816//
817RegError REGISTRY_CALLTYPE reg_setValue(RegKeyHandle hKey,
818 rtl_uString* keyName,
819 RegValueType valueType,
820 RegValue pData,
821 sal_uInt32 valueSize)
822{
823 if (!hKey)
824 return REG_INVALID_KEY;
825
826 return setValue(hKey, keyName, valueType, pData, valueSize);
827}
828
829//*********************************************************************
830// reg_setLongListValue
831//
832RegError REGISTRY_CALLTYPE reg_setLongListValue(RegKeyHandle hKey,
833 rtl_uString* keyName,
834 sal_Int32* pValueList,
835 sal_uInt32 len)
836{
837 if (!hKey)
838 return REG_INVALID_KEY;
839
840 return setLongListValue(hKey, keyName, pValueList, len);
841}
842
843//*********************************************************************
844// reg_setStringListValue
845//
846RegError REGISTRY_CALLTYPE reg_setStringListValue(RegKeyHandle hKey,
847 rtl_uString* keyName,
848 sal_Char** pValueList,
849 sal_uInt32 len)
850{
851 if (!hKey)
852 return REG_INVALID_KEY;
853
854 return setStringListValue(hKey, keyName, pValueList, len);
855}
856
857//*********************************************************************
858// reg_setUnicodeListValue
859//
860RegError REGISTRY_CALLTYPE reg_setUnicodeListValue(RegKeyHandle hKey,
861 rtl_uString* keyName,
862 sal_Unicode** pValueList,
863 sal_uInt32 len)
864{
865 if (!hKey)
866 return REG_INVALID_KEY;
867
868 return setUnicodeListValue(hKey, keyName, pValueList, len);
869}
870
871//*********************************************************************
872// reg_getValueInfo
873//
874RegError REGISTRY_CALLTYPE reg_getValueInfo(RegKeyHandle hKey,
875 rtl_uString* keyName,
876 RegValueType* pValueType,
877 sal_uInt32* pValueSize)
878{
879 if (!hKey)
880 return REG_INVALID_KEY;
881
882 return getValueInfo(hKey, keyName, pValueType, pValueSize);
883}
884
885//*********************************************************************
886// reg_getValueInfo
887//
888RegError REGISTRY_CALLTYPE reg_getValue(RegKeyHandle hKey,
889 rtl_uString* keyName,
890 RegValue pData)
891{
892 if (!hKey)
893 return REG_INVALID_KEY;
894
895 return getValue(hKey, keyName, pData);
896}
897
898//*********************************************************************
899// reg_getLongListValue
900//
901RegError REGISTRY_CALLTYPE reg_getLongListValue(RegKeyHandle hKey,
902 rtl_uString* keyName,
903 sal_Int32** pValueList,
904 sal_uInt32* pLen)
905{
906 if (!hKey)
907 return REG_INVALID_KEY;
908
909 return getLongListValue(hKey, keyName, pValueList, pLen);
910}
911
912//*********************************************************************
913// reg_getStringListValue
914//
915RegError REGISTRY_CALLTYPE reg_getStringListValue(RegKeyHandle hKey,
916 rtl_uString* keyName,
917 sal_Char*** pValueList,
918 sal_uInt32* pLen)
919{
920 if (!hKey)
921 return REG_INVALID_KEY;
922
923 return getStringListValue(hKey, keyName, pValueList, pLen);
924}
925
926//*********************************************************************
927// reg_getUnicodeListValue
928//
929RegError REGISTRY_CALLTYPE reg_getUnicodeListValue(RegKeyHandle hKey,
930 rtl_uString* keyName,
931 sal_Unicode*** pValueList,
932 sal_uInt32* pLen)
933{
934 if (!hKey)
1
Taking false branch
935 return REG_INVALID_KEY;
936
937 return getUnicodeListValue(hKey, keyName, pValueList, pLen);
2
Calling 'getUnicodeListValue'
938}
939
940//*********************************************************************
941// reg_freeValueList
942//
943RegError REGISTRY_CALLTYPE reg_freeValueList(RegValueType valueType,
944 RegValue pValueList,
945 sal_uInt32 len)
946{
947 if (pValueList)
948 return freeValueList(valueType, pValueList, len);
949 else
950 return REG_INVALID_VALUE;
951}
952
953//*********************************************************************
954// reg_getKeyType
955//
956RegError REGISTRY_CALLTYPE reg_getKeyType(RegKeyHandle hKey,
957 rtl_uString* keyName,
958 RegKeyType* pKeyType)
959{
960 if (!hKey)
961 return REG_INVALID_KEY;
962
963 return getKeyType(hKey, keyName, pKeyType);
964}
965
966//*********************************************************************
967// reg_getResolvedKeyName
968//
969RegError REGISTRY_CALLTYPE reg_getResolvedKeyName(RegKeyHandle hKey,
970 rtl_uString* keyName,
971 sal_Bool firstLinkOnly,
972 rtl_uString** pResolvedName)
973{
974 if (!hKey)
975 return REG_INVALID_KEY;
976
977 return getResolvedKeyName(hKey, keyName, firstLinkOnly, pResolvedName);
978}
979
980/* vim:set shiftwidth=4 softtabstop=4 expandtab: */