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