diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 14:18:43 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 14:18:43 +0000 |
commit | 9399c662f36c385b0c705eb34e636a9aec450282 (patch) | |
tree | f502e9d9258960ff214ab90e98e31d0075e60196 /registry |
initial import
Diffstat (limited to 'registry')
30 files changed, 15618 insertions, 0 deletions
diff --git a/registry/inc/registry/reflread.hxx b/registry/inc/registry/reflread.hxx new file mode 100644 index 000000000000..352cf7980dfe --- /dev/null +++ b/registry/inc/registry/reflread.hxx @@ -0,0 +1,499 @@ +/************************************************************************* + * + * $RCSfile: reflread.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/************************************************************************* + + Source Code Control System - Update + + $Log: not supported by cvs2svn $ + Revision 1.20 2000/09/17 12:30:32 willem.vandorp + OpenOffice header added. + + Revision 1.19 2000/08/04 15:31:39 jsc + extend biniary type format + + Revision 1.18 2000/07/26 17:44:32 willem.vandorp + Headers/footers replaced + + Revision 1.17 2000/05/02 06:06:21 jsc + insert LIBRARY_VERSION for dynamic loading + + Revision 1.16 2000/04/18 10:09:48 jsc + modified for unicode changes + + Revision 1.15 2000/03/24 15:00:36 jsc + modified for unicode changes + + Revision 1.14 1999/10/19 16:13:55 kr + Parameter for Version 1 of Registry added. + + Revision 1.13 1999/09/06 08:33:00 jsc + insert IDL filename in registry + + Revision 1.12 1999/07/02 09:25:39 jsc + #67179# Binaerblop der CoreReflection ist erweitert worden + + Revision 1.11 1999/03/12 14:16:38 jsc + #61011# Anpassung an osl-Typen + + Revision 1.10 1999/02/05 09:44:33 jsc + #61011# Typanpassung + + Revision 1.9 1998/12/11 11:57:42 jsc + Anpassung an ODynamicLoader + + Revision 1.8 1998/08/06 09:43:43 jsc + #54698# Anpassung an DynamicLoader + + Revision 1.7 1998/07/06 17:00:31 jsc + Calltype von InitRegistryTypeReader_Api gesetzt + + Revision 1.6 1998/07/03 11:20:07 ts + prefixen von typen + + Revision 1.5 1998/07/03 08:41:02 ts + bugs und set/getUik() + + Revision 1.4 1998/07/02 11:58:29 jsc + Typ Anpassung, Schnittstelle frei von solar.h + + Revision 1.3 1998/07/01 13:39:01 ts + bugs, bugs, bugs + + Revision 1.2 1998/06/30 13:42:27 ts + Anpassung an SOLARIS + + Revision 1.1.1.1 1998/06/30 11:17:45 jsc + neu + + +*************************************************************************/ + +#ifndef __REGISTRY_REFLREAD_HXX__ +#define __REGISTRY_REFLREAD_HXX__ + +#ifndef _REGISTRY_REFLTYPE_HXX_ +#include <registry/refltype.hxx> +#endif +#ifndef _REGISTRY_REGTYPE_H_ +#include <registry/regtype.h> +#endif +#ifndef _VOS_DYNLOAD_HXX_ +#include <vos/dynload.hxx> +#endif + +// Implememetation handle +typedef void* TypeReaderImpl; + +/**************************************************************************** + + C-Api for load on call + +*****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +struct RegistryTypeReader_Api +{ + TypeReaderImpl (TYPEREG_CALLTYPE *createEntry) (const sal_uInt8*, sal_uInt32, sal_Bool); + void (TYPEREG_CALLTYPE *acquire) (TypeReaderImpl); + void (TYPEREG_CALLTYPE *release) (TypeReaderImpl); + sal_uInt16 (TYPEREG_CALLTYPE *getMinorVersion) (TypeReaderImpl); + sal_uInt16 (TYPEREG_CALLTYPE *getMajorVersion) (TypeReaderImpl); + RTTypeClass (TYPEREG_CALLTYPE *getTypeClass) (TypeReaderImpl); + void (TYPEREG_CALLTYPE *getUik) (TypeReaderImpl, RTUik*); + void (TYPEREG_CALLTYPE *getDoku) (TypeReaderImpl, rtl_uString**); + void (TYPEREG_CALLTYPE *getFileName) (TypeReaderImpl, rtl_uString**); + void (TYPEREG_CALLTYPE *getTypeName) (TypeReaderImpl, rtl_uString**); + void (TYPEREG_CALLTYPE *getSuperTypeName) (TypeReaderImpl, rtl_uString**); + sal_uInt32 (TYPEREG_CALLTYPE *getFieldCount) (TypeReaderImpl); + void (TYPEREG_CALLTYPE *getFieldName) (TypeReaderImpl, rtl_uString**, sal_uInt16); + void (TYPEREG_CALLTYPE *getFieldType) (TypeReaderImpl, rtl_uString**, sal_uInt16); + RTFieldAccess (TYPEREG_CALLTYPE *getFieldAccess) (TypeReaderImpl, sal_uInt16); + RTValueType (TYPEREG_CALLTYPE *getFieldConstValue) (TypeReaderImpl, sal_uInt16, RTConstValueUnion*); + void (TYPEREG_CALLTYPE *getFieldDoku) (TypeReaderImpl, rtl_uString**, sal_uInt16); + void (TYPEREG_CALLTYPE *getFieldFileName) (TypeReaderImpl, rtl_uString**, sal_uInt16); + sal_uInt32 (TYPEREG_CALLTYPE *getMethodCount) (TypeReaderImpl); + void (TYPEREG_CALLTYPE *getMethodName) (TypeReaderImpl, rtl_uString**, sal_uInt16); + sal_uInt32 (TYPEREG_CALLTYPE *getMethodParamCount) (TypeReaderImpl, sal_uInt16); + void (TYPEREG_CALLTYPE *getMethodParamType) (TypeReaderImpl, rtl_uString**, sal_uInt16, sal_uInt16); + void (TYPEREG_CALLTYPE *getMethodParamName) (TypeReaderImpl, rtl_uString**, sal_uInt16, sal_uInt16); + RTParamMode (TYPEREG_CALLTYPE *getMethodParamMode) (TypeReaderImpl, sal_uInt16, sal_uInt16); + sal_uInt32 (TYPEREG_CALLTYPE *getMethodExcCount) (TypeReaderImpl, sal_uInt16); + void (TYPEREG_CALLTYPE *getMethodExcType) (TypeReaderImpl, rtl_uString**, sal_uInt16, sal_uInt16); + void (TYPEREG_CALLTYPE *getMethodReturnType) (TypeReaderImpl, rtl_uString**, sal_uInt16); + RTMethodMode (TYPEREG_CALLTYPE *getMethodMode) (TypeReaderImpl, sal_uInt16); + void (TYPEREG_CALLTYPE *getMethodDoku) (TypeReaderImpl, rtl_uString**, sal_uInt16); + + sal_uInt32 (TYPEREG_CALLTYPE *getReferenceCount) (TypeReaderImpl); + void (TYPEREG_CALLTYPE *getReferenceName) (TypeReaderImpl, rtl_uString**, sal_uInt16); + RTReferenceType (TYPEREG_CALLTYPE *getReferenceType) (TypeReaderImpl, sal_uInt16); + void (TYPEREG_CALLTYPE *getReferenceDoku) (TypeReaderImpl, rtl_uString**, sal_uInt16); + RTFieldAccess (TYPEREG_CALLTYPE *getReferenceAccess) (TypeReaderImpl, sal_uInt16); +}; + +typedef RegistryTypeReader_Api* (TYPEREG_CALLTYPE *InitRegistryTypeReader_Api)(void); + +#define REGISTRY_TYPE_READER_INIT_FUNCTION_NAME "initRegistryTypeReader_Api" + +#ifdef __cplusplus +} +#endif + + +/** RegistryTypeReaderLoader load the needed DLL for a RegistryTypeReader. + The loader can be checked if the DLL is loaded. If the DLL is loaded the + loader provides a valid Api for the RegistryTypeReader. +*/ +class RegistryTypeReaderLoader + : public ::vos::ODynamicLoader<RegistryTypeReader_Api> +{ +public: + RegistryTypeReaderLoader() + : ::vos::ODynamicLoader<RegistryTypeReader_Api> + (::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("reg") ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(REGISTRY_TYPE_READER_INIT_FUNCTION_NAME) ), + sal_True, LIBRARY_VERSION, sal_False) + {} + + ~RegistryTypeReaderLoader() + {} +}; + + +/** RegistryTypeReader reads type informations from a blop. + Class is inline and use a load on call C-Api. +*/ +class RegistryTypeReader +{ +public: + + inline RegistryTypeReader(const RegistryTypeReader_Api* pApi, + const sal_uInt8* buffer, + sal_uInt32 bufferLen, + sal_Bool copyData); + inline RegistryTypeReader(const RegistryTypeReaderLoader& rLoader, + const sal_uInt8* buffer, + sal_uInt32 bufferLen, + sal_Bool copyData); + inline RegistryTypeReader(const RegistryTypeReader& toCopy); + inline ~RegistryTypeReader(); + + inline RegistryTypeReader& operator == (const RegistryTypeReader& toAssign); + + inline sal_Bool isValid() const; + + inline sal_uInt16 getMinorVersion() const; + inline sal_uInt16 getMajorVersion() const; + inline RTTypeClass getTypeClass() const; + inline ::rtl::OUString getTypeName() const; + inline ::rtl::OUString getSuperTypeName() const; + inline void getUik(RTUik& uik) const; + inline ::rtl::OUString getDoku() const; + inline ::rtl::OUString getFileName() const; + inline sal_uInt32 getFieldCount() const; + inline ::rtl::OUString getFieldName( sal_uInt16 index ) const; + inline ::rtl::OUString getFieldType( sal_uInt16 index ) const; + inline RTFieldAccess getFieldAccess( sal_uInt16 index ) const; + inline RTConstValue getFieldConstValue( sal_uInt16 index ) const; + inline ::rtl::OUString getFieldDoku( sal_uInt16 index ) const; + inline ::rtl::OUString getFieldFileName( sal_uInt16 index ) const; + inline sal_uInt32 getMethodCount() const; + inline ::rtl::OUString getMethodName( sal_uInt16 index ) const; + inline sal_uInt32 getMethodParamCount( sal_uInt16 index ) const; + inline ::rtl::OUString getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const; + inline ::rtl::OUString getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const; + inline RTParamMode getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const; + inline sal_uInt32 getMethodExcCount( sal_uInt16 index ) const; + inline ::rtl::OUString getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const; + inline ::rtl::OUString getMethodReturnType( sal_uInt16 index ) const; + inline RTMethodMode getMethodMode( sal_uInt16 index ) const; + inline ::rtl::OUString getMethodDoku( sal_uInt16 index ) const; + + inline sal_uInt32 getReferenceCount() const; + inline ::rtl::OUString getReferenceName( sal_uInt16 index ) const; + inline RTReferenceType getReferenceType( sal_uInt16 index ) const; + inline ::rtl::OUString getReferenceDoku( sal_uInt16 index ) const; + inline RTFieldAccess getReferenceAccess( sal_uInt16 index ) const; + +protected: + + const RegistryTypeReader_Api* m_pApi; + const NAMESPACE_VOS(ODynamicLoader)<RegistryTypeReader_Api> m_Api; + TypeReaderImpl m_hImpl; +}; + + + +inline RegistryTypeReader::RegistryTypeReader(const RegistryTypeReader_Api* pApi, + const sal_uInt8* buffer, + sal_uInt32 bufferLen, + sal_Bool copyData) + : m_pApi(pApi) + , m_Api() + , m_hImpl(NULL) + { + m_hImpl = m_pApi->createEntry(buffer, bufferLen, copyData); + } + + +inline RegistryTypeReader::RegistryTypeReader(const RegistryTypeReaderLoader& rLoader, + const sal_uInt8* buffer, + sal_uInt32 bufferLen, + sal_Bool copyData) + : m_pApi(NULL) + , m_Api(rLoader) + , m_hImpl(NULL) + { + m_pApi = m_Api.getApi(); + m_hImpl = m_pApi->createEntry(buffer, bufferLen, copyData); + } + + +inline RegistryTypeReader::RegistryTypeReader(const RegistryTypeReader& toCopy) + : m_pApi(toCopy.m_pApi) + , m_Api(toCopy.m_Api) + , m_hImpl(toCopy.m_hImpl) + { m_pApi->acquire(m_hImpl); } + + +inline RegistryTypeReader::~RegistryTypeReader() + { m_pApi->release(m_hImpl); } + +inline RegistryTypeReader& RegistryTypeReader::operator == (const RegistryTypeReader& toAssign) +{ + if (m_hImpl != toAssign.m_hImpl) + { + m_pApi->release(m_hImpl); + m_hImpl = toAssign.m_hImpl; + m_pApi->acquire(m_hImpl); + } + + return *this; +} + +inline sal_uInt16 RegistryTypeReader::getMinorVersion() const + { return m_pApi->getMinorVersion(m_hImpl); } + +inline sal_Bool RegistryTypeReader::isValid() const + { return (m_hImpl != NULL); } + +inline sal_uInt16 RegistryTypeReader::getMajorVersion() const + { return m_pApi->getMajorVersion(m_hImpl); } + +inline RTTypeClass RegistryTypeReader::getTypeClass() const + { return m_pApi->getTypeClass(m_hImpl); } + +inline ::rtl::OUString RegistryTypeReader::getTypeName() const + { + ::rtl::OUString sRet; + m_pApi->getTypeName(m_hImpl, &sRet.pData); + return sRet; + } + +inline ::rtl::OUString RegistryTypeReader::getSuperTypeName() const + { + ::rtl::OUString sRet; + m_pApi->getSuperTypeName(m_hImpl, &sRet.pData); + return sRet; + } + +inline void RegistryTypeReader::getUik(RTUik& uik) const + { m_pApi->getUik(m_hImpl, &uik); } + +inline ::rtl::OUString RegistryTypeReader::getDoku() const + { + ::rtl::OUString sRet; + m_pApi->getDoku(m_hImpl, &sRet.pData); + return sRet; + } + +inline ::rtl::OUString RegistryTypeReader::getFileName() const + { + ::rtl::OUString sRet; + m_pApi->getFileName(m_hImpl, &sRet.pData); + return sRet; + } + +inline sal_uInt32 RegistryTypeReader::getFieldCount() const + { return m_pApi->getFieldCount(m_hImpl); } + +inline ::rtl::OUString RegistryTypeReader::getFieldName( sal_uInt16 index ) const + { + ::rtl::OUString sRet; + m_pApi->getFieldName(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline ::rtl::OUString RegistryTypeReader::getFieldType( sal_uInt16 index ) const + { + ::rtl::OUString sRet; + m_pApi->getFieldType(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline RTFieldAccess RegistryTypeReader::getFieldAccess( sal_uInt16 index ) const + { return m_pApi->getFieldAccess(m_hImpl, index); } + +inline RTConstValue RegistryTypeReader::getFieldConstValue( sal_uInt16 index ) const + { + RTConstValue ret; + ret.m_type = m_pApi->getFieldConstValue(m_hImpl, index, &ret.m_value); + return ret; + } + +inline ::rtl::OUString RegistryTypeReader::getFieldDoku( sal_uInt16 index ) const + { + ::rtl::OUString sRet; + m_pApi->getFieldDoku(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline ::rtl::OUString RegistryTypeReader::getFieldFileName( sal_uInt16 index ) const + { + ::rtl::OUString sRet; + m_pApi->getFieldFileName(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline sal_uInt32 RegistryTypeReader::getMethodCount() const + { return m_pApi->getMethodCount(m_hImpl); } + +inline ::rtl::OUString RegistryTypeReader::getMethodName( sal_uInt16 index ) const + { + ::rtl::OUString sRet; + m_pApi->getMethodName(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline sal_uInt32 RegistryTypeReader::getMethodParamCount( sal_uInt16 index ) const + { return m_pApi->getMethodParamCount(m_hImpl, index); } + +inline ::rtl::OUString RegistryTypeReader::getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const + { + ::rtl::OUString sRet; + m_pApi->getMethodParamType(m_hImpl, &sRet.pData, index, paramIndex); + return sRet; + } + +inline ::rtl::OUString RegistryTypeReader::getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const + { + ::rtl::OUString sRet; + m_pApi->getMethodParamName(m_hImpl, &sRet.pData, index, paramIndex); + return sRet; + } + +inline RTParamMode RegistryTypeReader::getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const + { return m_pApi->getMethodParamMode(m_hImpl, index, paramIndex); } + +inline sal_uInt32 RegistryTypeReader::getMethodExcCount( sal_uInt16 index ) const + { return m_pApi->getMethodExcCount(m_hImpl, index); } + +inline ::rtl::OUString RegistryTypeReader::getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const + { + ::rtl::OUString sRet; + m_pApi->getMethodExcType(m_hImpl, &sRet.pData, index, excIndex); + return sRet; + } + +inline ::rtl::OUString RegistryTypeReader::getMethodReturnType( sal_uInt16 index ) const + { + ::rtl::OUString sRet; + m_pApi->getMethodReturnType(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline RTMethodMode RegistryTypeReader::getMethodMode( sal_uInt16 index ) const + { return m_pApi->getMethodMode(m_hImpl, index); } + +inline ::rtl::OUString RegistryTypeReader::getMethodDoku( sal_uInt16 index ) const + { + ::rtl::OUString sRet; + m_pApi->getMethodDoku(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline sal_uInt32 RegistryTypeReader::getReferenceCount() const + { return m_pApi->getReferenceCount(m_hImpl); } + +inline ::rtl::OUString RegistryTypeReader::getReferenceName( sal_uInt16 index ) const + { + ::rtl::OUString sRet; + m_pApi->getReferenceName(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline RTReferenceType RegistryTypeReader::getReferenceType( sal_uInt16 index ) const + { return m_pApi->getReferenceType(m_hImpl, index); } + +inline ::rtl::OUString RegistryTypeReader::getReferenceDoku( sal_uInt16 index ) const + { + ::rtl::OUString sRet; + m_pApi->getReferenceDoku(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline RTFieldAccess RegistryTypeReader::getReferenceAccess( sal_uInt16 index ) const + { return m_pApi->getReferenceAccess(m_hImpl, index); } + +#endif diff --git a/registry/inc/registry/refltype.hxx b/registry/inc/registry/refltype.hxx new file mode 100644 index 000000000000..7e217e7e84f7 --- /dev/null +++ b/registry/inc/registry/refltype.hxx @@ -0,0 +1,266 @@ +/************************************************************************* + * + * $RCSfile: refltype.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/************************************************************************* + + Source Code Control System - Update + + $Log: not supported by cvs2svn $ + Revision 1.19 2000/09/17 12:30:32 willem.vandorp + OpenOffice header added. + + Revision 1.18 2000/08/04 15:31:39 jsc + extend biniary type format + + Revision 1.17 2000/07/26 17:44:32 willem.vandorp + Headers/footers replaced + + Revision 1.16 2000/03/24 15:00:36 jsc + modified for unicode changes + + Revision 1.15 2000/02/08 16:01:09 hr + #70473# changes for unicode ( patched by automated patchtool ) + + Revision 1.14 1999/10/22 09:58:47 jsc + TYPEREG_CALLTYPE = SAL_CALL + + Revision 1.13 1999/10/21 15:48:50 jsc + optional flag now in registry + + Revision 1.12 1999/10/15 11:05:51 dbo + short RTConstValue from sal_uInt16 to sal_Int16 + + Revision 1.11 1999/07/02 09:25:40 jsc + #67179# Binaerblop der CoreReflection ist erweitert worden + + Revision 1.10 1999/03/12 14:16:38 jsc + #61011# Anpassung an osl-Typen + + Revision 1.9 1998/07/03 12:36:16 ts + added SERVICE and OBJECT + + Revision 1.8 1998/07/03 11:20:07 ts + prefixen von typen + + Revision 1.7 1998/07/03 10:55:41 ts + added RT_TYPE_TYPEDEF + + Revision 1.6 1998/07/03 08:41:02 ts + bugs und set/getUik() + + Revision 1.5 1998/07/02 11:58:47 jsc + Typ Anpassung, Schnittstelle frei von solar.h + + Revision 1.4 1998/07/01 16:55:19 ts + alignment unter soaris beachten + + Revision 1.3 1998/07/01 13:39:01 ts + bugs, bugs, bugs + + Revision 1.2 1998/06/30 13:42:27 ts + Anpassung an SOLARIS + + Revision 1.1.1.1 1998/06/30 11:17:45 jsc + neu + + +*************************************************************************/ + +#ifndef __REGISTRY_REFLTYPE_HXX__ +#define __REGISTRY_REFLTYPE_HXX__ + +#ifdef SOLARIS +#include <wchar.h> +#else +#include <stdlib.h> +#endif + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +enum RTTypeClass +{ + RT_TYPE_INVALID, + RT_TYPE_INTERFACE, + RT_TYPE_MODULE, + RT_TYPE_STRUCT, + RT_TYPE_ENUM, + RT_TYPE_EXCEPTION, + RT_TYPE_TYPEDEF, + RT_TYPE_SERVICE, + RT_TYPE_OBJECT, + RT_TYPE_CONSTANTS +}; + +typedef sal_uInt16 RTFieldAccess; + +#define RT_ACCESS_INVALID 0x0000 +#define RT_ACCESS_READONLY 0x0001 +#define RT_ACCESS_OPTIONAL 0x0002 +#define RT_ACCESS_MAYBEVOID 0x0004 +#define RT_ACCESS_BOUND 0x0008 +#define RT_ACCESS_CONSTRAINED 0x0010 +#define RT_ACCESS_TRANSIENT 0x0020 +#define RT_ACCESS_MAYBEAMBIGUOUS 0x0040 +#define RT_ACCESS_MAYBEDEFAULT 0x0080 +#define RT_ACCESS_REMOVEABLE 0x0100 +#define RT_ACCESS_ATTRIBUTE 0x0200 +#define RT_ACCESS_PROPERTY 0x0400 +#define RT_ACCESS_CONST 0x0800 +#define RT_ACCESS_READWRITE 0x1000 +/* +enum RTFieldAccess +{ + RT_ACCESS_INVALID, + RT_ACCESS_CONST, + RT_ACCESS_READONLY, + RT_ACCESS_WRITEONLY, + RT_ACCESS_READWRITE, + RT_ACCESS_READONLY_OPTIONAL, + RT_ACCESS_WRITEONLY_OPTIONAL, + RT_ACCESS_READWRITE_OPTIONAL +}; +*/ +enum RTReferenceType +{ + RT_REF_INVALID, + RT_REF_SUPPORTS, + RT_REF_OBSERVES, + RT_REF_EXPORTS, + RT_REF_NEEDS +}; + +enum RTMethodMode +{ + RT_MODE_INVALID, + RT_MODE_ONEWAY, + RT_MODE_ONEWAY_CONST, + RT_MODE_TWOWAY, + RT_MODE_TWOWAY_CONST +}; + +enum RTParamMode +{ + RT_PARAM_INVALID, + RT_PARAM_IN, + RT_PARAM_OUT, + RT_PARAM_INOUT +}; + +enum RTValueType +{ + RT_TYPE_NONE, + RT_TYPE_BOOL, + RT_TYPE_BYTE, + RT_TYPE_INT16, + RT_TYPE_UINT16, + RT_TYPE_INT32, + RT_TYPE_UINT32, + RT_TYPE_INT64, + RT_TYPE_UINT64, + RT_TYPE_FLOAT, + RT_TYPE_DOUBLE, + RT_TYPE_STRING +}; + +union RTConstValueUnion +{ + sal_Bool aBool; + sal_uInt8 aByte; + sal_Int16 aShort; + sal_uInt16 aUShort; + sal_Int32 aLong; + sal_uInt32 aULong; +// sal_Int64 aHyper; +// sal_UInt64 aUHyper; + float aFloat; + double aDouble; + const sal_Unicode* aString; +}; + +class RTConstValue +{ +public: + RTValueType m_type; + RTConstValueUnion m_value; + + RTConstValue() + : m_type(RT_TYPE_NONE) + { + m_value.aDouble = 0.0; + } + + ~RTConstValue() {}; +}; + +struct RTUik +{ + sal_uInt32 m_Data1; + sal_uInt16 m_Data2; + sal_uInt16 m_Data3; + sal_uInt32 m_Data4; + sal_uInt32 m_Data5; +}; + +#define TYPEREG_CALLTYPE SAL_CALL + +#endif diff --git a/registry/inc/registry/reflwrit.hxx b/registry/inc/registry/reflwrit.hxx new file mode 100644 index 000000000000..ae96e0284776 --- /dev/null +++ b/registry/inc/registry/reflwrit.hxx @@ -0,0 +1,422 @@ +/************************************************************************* + * + * $RCSfile: reflwrit.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/************************************************************************* + + Source Code Control System - Update + + $Log: not supported by cvs2svn $ + Revision 1.20 2000/09/17 12:30:32 willem.vandorp + OpenOffice header added. + + Revision 1.19 2000/08/04 15:31:39 jsc + extend biniary type format + + Revision 1.18 2000/07/26 17:44:32 willem.vandorp + Headers/footers replaced + + Revision 1.17 2000/05/02 06:06:21 jsc + insert LIBRARY_VERSION for dynamic loading + + Revision 1.16 2000/04/18 10:09:48 jsc + modified for unicode changes + + Revision 1.15 2000/03/24 15:00:36 jsc + modified for unicode changes + + Revision 1.14 1999/10/19 16:14:49 kr + Version parameter for dynload added + + Revision 1.13 1999/09/06 08:33:00 jsc + insert IDL filename in registry + + Revision 1.12 1999/07/02 09:25:40 jsc + #67179# Binaerblop der CoreReflection ist erweitert worden + + Revision 1.11 1999/03/12 14:16:38 jsc + #61011# Anpassung an osl-Typen + + Revision 1.10 1999/02/05 09:44:33 jsc + #61011# Typanpassung + + Revision 1.9 1998/12/11 11:57:42 jsc + Anpassung an ODynamicLoader + + Revision 1.8 1998/08/06 09:43:44 jsc + #54698# Anpassung an DynamicLoader + + Revision 1.7 1998/07/06 17:02:03 jsc + Calltype von InitRegistryTypeWriter_Api gesetzt + + Revision 1.6 1998/07/03 11:20:08 ts + prefixen von typen + + Revision 1.5 1998/07/03 08:41:03 ts + bugs und set/getUik() + + Revision 1.4 1998/07/02 11:58:39 jsc + Typ Anpassung, Schnittstelle frei von solar.h + + Revision 1.3 1998/07/01 16:55:19 ts + alignment unter soaris beachten + + Revision 1.2 1998/07/01 13:39:01 ts + bugs, bugs, bugs + + Revision 1.1.1.1 1998/06/30 11:17:45 jsc + neu + + +*************************************************************************/ + +#ifndef __REGISTRY_REFLWRIT_HXX__ +#define __REGISTRY_REFLWRIT_HXX__ + +#ifndef _REGISTRY_REFLTYPE_HXX_ +#include <registry/refltype.hxx> +#endif +#ifndef _REGISTRY_REGTYPE_H_ +#include <registry/regtype.h> +#endif +#ifndef _VOS_DYNLOAD_HXX_ +#include <vos/dynload.hxx> +#endif + +// Implememetation handle +typedef void* TypeWriterImpl; + +/**************************************************************************** + + C-Api for load on call + +*****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +struct RegistryTypeWriter_Api +{ + TypeWriterImpl (TYPEREG_CALLTYPE *createEntry) (RTTypeClass, rtl_uString*, rtl_uString*, sal_uInt16, sal_uInt16, sal_uInt16); + void (TYPEREG_CALLTYPE *acquire) (TypeWriterImpl); + void (TYPEREG_CALLTYPE *release) (TypeWriterImpl); + void (TYPEREG_CALLTYPE *setUik) (TypeWriterImpl, const RTUik*); + void (TYPEREG_CALLTYPE *setDoku) (TypeWriterImpl, rtl_uString*); + void (TYPEREG_CALLTYPE *setFileName) (TypeWriterImpl, rtl_uString*); + void (TYPEREG_CALLTYPE *setFieldData) (TypeWriterImpl, sal_uInt16, rtl_uString*, rtl_uString*, rtl_uString*, rtl_uString*, RTFieldAccess, RTValueType, RTConstValueUnion); + void (TYPEREG_CALLTYPE *setMethodData) (TypeWriterImpl, sal_uInt16, rtl_uString*, rtl_uString*, RTMethodMode, sal_uInt16, sal_uInt16, rtl_uString*); + void (TYPEREG_CALLTYPE *setParamData) (TypeWriterImpl, sal_uInt16, sal_uInt16, rtl_uString*, rtl_uString*, RTParamMode); + void (TYPEREG_CALLTYPE *setExcData) (TypeWriterImpl, sal_uInt16, sal_uInt16, rtl_uString*); + const sal_uInt8* (TYPEREG_CALLTYPE *getBlop) (TypeWriterImpl); + sal_uInt32 (TYPEREG_CALLTYPE *getBlopSize) (TypeWriterImpl); + + void (TYPEREG_CALLTYPE *setReferenceData) (TypeWriterImpl, sal_uInt16, rtl_uString*, RTReferenceType, rtl_uString*, RTFieldAccess); +}; + +typedef RegistryTypeWriter_Api* (TYPEREG_CALLTYPE *InitRegistryTypeWriter_Api)(void); + +#define REGISTRY_TYPE_WRITER_INIT_FUNCTION_NAME "initRegistryTypeWriter_Api" + +#ifdef __cplusplus +} +#endif + + +/** RegistryTypeWriterLoader load the needed DLL for a RegistryTypeWriter. + The loader can be checked if the DLL is loaded. If the DLL is loaded the + loader provides a valid Api for the RegistryTypeWriter. +*/ +class RegistryTypeWriterLoader + : public ::vos::ODynamicLoader<RegistryTypeWriter_Api> +{ +public: + RegistryTypeWriterLoader() + : ::vos::ODynamicLoader<RegistryTypeWriter_Api> + (::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("reg") ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(REGISTRY_TYPE_WRITER_INIT_FUNCTION_NAME) ), + sal_True, LIBRARY_VERSION, sal_False) + {} + + ~RegistryTypeWriterLoader() + {} +}; + + +/** RegistryTypeWriter writes type informations into a blop. + Class is inline and use a load on call C-Api. +*/ +class RegistryTypeWriter +{ +public: + + inline RegistryTypeWriter(const RegistryTypeWriter_Api* pApi, + RTTypeClass RTTypeClass, + const ::rtl::OUString& typeName, + const ::rtl::OUString& superTypeName, + sal_uInt16 fieldCount, + sal_uInt16 methodCount, + sal_uInt16 referenceCount); + + inline RegistryTypeWriter(const RegistryTypeWriterLoader& rLoader, + RTTypeClass RTTypeClass, + const ::rtl::OUString& typeName, + const ::rtl::OUString& superTypeName, + sal_uInt16 fieldCount, + sal_uInt16 methodCount, + sal_uInt16 referenceCount); + + inline RegistryTypeWriter(const RegistryTypeWriter& toCopy); + inline ~RegistryTypeWriter(); + + inline RegistryTypeWriter& operator == (const RegistryTypeWriter& toAssign); + + inline void setUik(const RTUik& uik); + + inline void setDoku(const ::rtl::OUString& doku); + + inline void setFileName(const ::rtl::OUString& fileName); + + inline void setFieldData( sal_uInt16 index, + const ::rtl::OUString& name, + const ::rtl::OUString& typeName, + const ::rtl::OUString& doku, + const ::rtl::OUString& fileName, + RTFieldAccess access, + RTConstValue constValue = RTConstValue()); + + inline void setMethodData(sal_uInt16 index, + const ::rtl::OUString& name, + const ::rtl::OUString& returnTypeName, + RTMethodMode mode, + sal_uInt16 paramCount, + sal_uInt16 excCount, + const ::rtl::OUString& doku); + + inline void setParamData(sal_uInt16 index, + sal_uInt16 paramIndex, + const ::rtl::OUString& type, + const ::rtl::OUString& name, + RTParamMode mode); + + inline void setExcData(sal_uInt16 index, + sal_uInt16 excIndex, + const ::rtl::OUString& type); + + inline const sal_uInt8* getBlop(); + inline sal_uInt32 getBlopSize(); + + inline void setReferenceData( sal_uInt16 index, + const ::rtl::OUString& name, + RTReferenceType refType, + const ::rtl::OUString& doku, + RTFieldAccess access = RT_ACCESS_INVALID); + +protected: + + const RegistryTypeWriter_Api* m_pApi; + const NAMESPACE_VOS(ODynamicLoader)<RegistryTypeWriter_Api> m_Api; + TypeWriterImpl m_hImpl; +}; + + + +inline RegistryTypeWriter::RegistryTypeWriter(const RegistryTypeWriter_Api* pApi, + RTTypeClass RTTypeClass, + const ::rtl::OUString& typeName, + const ::rtl::OUString& superTypeName, + sal_uInt16 fieldCount, + sal_uInt16 methodCount, + sal_uInt16 referenceCount) + : m_pApi(pApi) + , m_Api() + , m_hImpl(NULL) +{ + m_hImpl = m_pApi->createEntry(RTTypeClass, + typeName.pData, + superTypeName.pData, + fieldCount, + methodCount, + referenceCount); +} + + +inline RegistryTypeWriter::RegistryTypeWriter(const RegistryTypeWriterLoader& rLoader, + RTTypeClass RTTypeClass, + const ::rtl::OUString& typeName, + const ::rtl::OUString& superTypeName, + sal_uInt16 fieldCount, + sal_uInt16 methodCount, + sal_uInt16 referenceCount) + : m_pApi(NULL) + , m_Api(rLoader) + , m_hImpl(NULL) +{ + m_pApi = m_Api.getApi(); + m_hImpl = m_pApi->createEntry(RTTypeClass, + typeName.pData, + superTypeName.pData, + fieldCount, + methodCount, + referenceCount); +} + + +inline RegistryTypeWriter::RegistryTypeWriter(const RegistryTypeWriter& toCopy) + : m_pApi(toCopy.m_pApi) + , m_Api(toCopy.m_Api) + , m_hImpl(toCopy.m_hImpl) +{ + m_Api->acquire(m_hImpl); +} + +inline RegistryTypeWriter::~RegistryTypeWriter() +{ + m_pApi->release(m_hImpl); +} + +inline RegistryTypeWriter& RegistryTypeWriter::operator == (const RegistryTypeWriter& toAssign) +{ + if (m_hImpl != toAssign.m_hImpl) + { + m_pApi->release(m_hImpl); + m_hImpl = toAssign.m_hImpl; + m_pApi->acquire(m_hImpl); + } + + return *this; +} + +inline void RegistryTypeWriter::setFieldData( sal_uInt16 index, + const ::rtl::OUString& name, + const ::rtl::OUString& typeName, + const ::rtl::OUString& doku, + const ::rtl::OUString& fileName, + RTFieldAccess access, + RTConstValue constValue) +{ + m_pApi->setFieldData(m_hImpl, index, name.pData, typeName.pData, doku.pData, fileName.pData, access, constValue.m_type, constValue.m_value); +} + + +inline void RegistryTypeWriter::setMethodData(sal_uInt16 index, + const ::rtl::OUString& name, + const ::rtl::OUString& returnTypeName, + RTMethodMode mode, + sal_uInt16 paramCount, + sal_uInt16 excCount, + const ::rtl::OUString& doku) +{ + m_pApi->setMethodData(m_hImpl, index, name.pData, returnTypeName.pData, mode, paramCount, excCount, doku.pData); +} + + +inline void RegistryTypeWriter::setUik(const RTUik& uik) +{ + m_pApi->setUik(m_hImpl, &uik); +} + +inline void RegistryTypeWriter::setDoku(const ::rtl::OUString& doku) +{ + m_pApi->setDoku(m_hImpl, doku.pData); +} + +inline void RegistryTypeWriter::setFileName(const ::rtl::OUString& doku) +{ + m_pApi->setFileName(m_hImpl, doku.pData); +} + +inline void RegistryTypeWriter::setParamData(sal_uInt16 index, + sal_uInt16 paramIndex, + const ::rtl::OUString& type, + const ::rtl::OUString& name, + RTParamMode mode) +{ + m_pApi->setParamData(m_hImpl, index, paramIndex, type.pData, name.pData, mode); +} + +inline void RegistryTypeWriter::setExcData(sal_uInt16 index, + sal_uInt16 excIndex, + const ::rtl::OUString& type) +{ + m_pApi->setExcData(m_hImpl, index, excIndex, type.pData); +} + +inline const sal_uInt8* RegistryTypeWriter::getBlop() +{ + return m_pApi->getBlop(m_hImpl); +} + +inline sal_uInt32 RegistryTypeWriter::getBlopSize() +{ + return m_pApi->getBlopSize(m_hImpl); +} + + +inline void RegistryTypeWriter::setReferenceData( sal_uInt16 index, + const ::rtl::OUString& name, + RTReferenceType refType, + const ::rtl::OUString& doku, + RTFieldAccess access) +{ + m_pApi->setReferenceData(m_hImpl, index, name.pData, refType, doku.pData, access); +} + +#endif diff --git a/registry/inc/registry/registry.h b/registry/inc/registry/registry.h new file mode 100644 index 000000000000..392fb8b82fe2 --- /dev/null +++ b/registry/inc/registry/registry.h @@ -0,0 +1,456 @@ +/************************************************************************* + * + * $RCSfile: registry.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _REGISTRY_REGISTRY_H_ +#define _REGISTRY_REGISTRY_H_ + +#include <stddef.h> + +#ifndef _RTL_USTRING_H_ +#include <rtl/ustring.h> +#endif +#ifndef _REGISTRY_REGTYPE_H_ +#include <registry/regtype.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** This function creates the specified key. If the key already exists in the registry, + the function opens it. + @param hKey Identifies a currently open key. The key opened or created by this function + is a subkey of the key identified by hKey. + @param keyName Points to a null terminated string specifying the name of a key that this + function opens or creates. + @param phNewKey Points to a variable that receives the handle of the opened or created key. + Memory to store this variable is allocated and is freed with the function + closeRegKey. If the function fails, phNewKey is NULL. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_createKey(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle* phNewKey); + + +/** This function opens the specified key. + @param hKey Identifies a currently open key. The key opened by this function + is a subkey of the key identified by hKey + @param keyName Points to a null terminated string specifying the name of a key that this + function opens. + @param phNewKey Points to a variable that receives the handle of the opened key. + Memory to store this variable is allocated and is freed with the function + reg_closeKey. If the function fails, phNewKey is NULL. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_openKey(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle* phOpenKey); + + + +/** This function opens all subkeys of the specified key. + @param hKey Identifies a currently open key. The key that subkeys opened by this + function is a subkey of the key identified by hKey + @param keyName Points to a null terminated string specifying the name of a key that subkeys + this function opens. + @param pphSubKeys Points to a variable that receives an array of of all opened subkeys. + Memory to store this variable is allocated and is freed with the function + reg_closeSubKeys. If the function fails, pphSubKeys is NULL. + @param pnSubKeys Specified the length of the array (the number of open subkeys). + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_openSubKeys(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle** pphSubKeys, + sal_uInt32* pnSubKeys); + + +/** This function close all subkeys specified in the array. + @param phSubKeys Points to a variable that containss an array of of all opened subkeys. + The allocated memory of pphSubKeys and all open subkeys is freed. + @param nSubKeys Specified the length of the array (the number of subkeys to closed). + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_closeSubKeys(RegKeyHandle* phSubKeys, + sal_uInt32 nSubKeys); + + +/** This function deletes the specified key. + @param hKey Identifies a currently open key. The key deleted by this function + is a subkey of the key identified by hKey + @param keyName Points to a null terminated string specifying the name of a key that this + function deletes. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_deleteKey(RegKeyHandle hKey, + rtl_uString* keyName); + + +/** This function closes the specified key. + @param hKey Identifies a currently open key. The key is closed by this function. + The memory of the variable specifying the key is freeing. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_closeKey(RegKeyHandle hKey); + + +/** This function returns the name of the key. + @param hKey Identifies a currently open key which name will returned. + @param pKeyName contains the keyname if succeeds else an empty string. +*/ +const RegError REGISTRY_CALLTYPE reg_getKeyName(RegKeyHandle hKey, rtl_uString** pKeyName); + + +/** This function sets an value under the specified key. + @param hKey Identifies a currently open key. The key which value is setted by this + function is a subkey of the key identified by hKey. + @param keyName Points to a null terminated string specifying the name of a key which value + is set by this function. If keyName is NULL, the value is set for the key + specified by hKey. + @param valueType Specified the type of the value. + @param pData Points to a memory block containing the current data for the value. + @param valueSize Specified the size of pData in bytes + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_setValue(RegKeyHandle hKey, + rtl_uString* keyName, + RegValueType valueType, + RegValue pData, + sal_uInt32 valueSize); + + +/** This function sets an long list value under the key. + @param keyName Points to a null terminated string specifying the name of a key which value + is set by this function. If keyName is NULL, the value is set for the key + specified by hKey. + @param pValueList Points to an array of longs containing the current data for the value. + @param len Specified the len of pValueList. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_setLongListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Int32* pValueList, + sal_uInt32 len); + + +/** This function sets an ascii list value under the key. + @param keyName Points to a null terminated string specifying the name of a key which value + is set by this function. If keyName is NULL, the value is set for the key + specified by hKey. + @param pValueList Points to an array of sal_Char* containing the current data for the value. + @param len Specified the len of pValueList. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_setStringListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Char** pValueList, + sal_uInt32 len); + + +/** This function sets an unicode string list value under the key. + @param keyName Points to a null terminated string specifying the name of a key which value + is set by this function. If keyName is NULL, the value is set for the key + specified by hKey. + @param pValueList Points to an array of sal_Unicode* containing the current data for the value. + @param len Specified the len of pValueList. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_setUnicodeListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Unicode** pValueList, + sal_uInt32 len); + + +/** This function gets info about type and size of the value. + @param hKey Identifies a currently open key. The key which value info is getted by this + function is a subkey of the key identified by hKey. + @param keyName Points to a null terminated string specifying the name of a key which value + is get by this function. If keyName is NULL, the value info is get from the + key specified by hKey. + @param pValueType Specified the type of the value. + @param pValueSize Specified the size of pData in bytes + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_getValueInfo(RegKeyHandle hKey, + rtl_uString* keyName, + RegValueType* pValueType, + sal_uInt32* pValueSize); + + +/** This function gets the value under the specified key. + @param hKey Identifies a currently open key. The key which value is getted by this + function is a subkey of the key identified by hKey. + @param keyName Points to a null terminated string specifying the name of a key which value + is get by this function. If keyName is NULL, the value is get from the key + specified by hKey. + @param pData Points to an allocated memory block receiving the current data for the value. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_getValue(RegKeyHandle hKey, + rtl_uString* keyName, + RegValue pData); + + +/** This function gets the value under the specified key. + @param keyName Points to a null terminated string specifying the name of a key which value + is get by this function. If keyName is NULL, the value is get from the key + specified by hKey. + @param pValueList A Pointer to a long value list. + @param pLen Specifies the length of the value list. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_getLongListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Int32** pValueList, + sal_uInt32* pLen); + + +/** This function gets the value under the specified key. + @param keyName Points to a null terminated string specifying the name of a key which value + is get by this function. If keyName is NULL, the value is get from the key + specified by hKey. + @param pValueList A Pointer to a ascii value list. + @param pLen Specifies the length of the value list. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_getStringListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Char*** pValueList, + sal_uInt32* pLen); + + +/** This function gets the value under the specified key. + @param keyName Points to a null terminated string specifying the name of a key which value + is get by this function. If keyName is NULL, the value is get from the key + specified by hKey. + @param pValueList A Pointer to a unicode value list. + @param pLen Specifies the length of the value list. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_getUnicodeListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Unicode*** pValueList, + sal_uInt32* pLen); + + +/** This function free a value list. + @param valueType Specifies the type of the list members. + @param pValueList A Pointer to value list. + @param pLen Specifies the length of the value list. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_freeValueList(RegValueType valueType, + RegValue pValueList, + sal_uInt32 len); + +RegError REGISTRY_CALLTYPE reg_createLink(RegKeyHandle hKey, + rtl_uString* linkName, + rtl_uString* linkTarget); + +RegError REGISTRY_CALLTYPE reg_deleteLink(RegKeyHandle hKey, + rtl_uString* linkName); + +RegError REGISTRY_CALLTYPE reg_getKeyType(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyType* pKeyType); + +RegError REGISTRY_CALLTYPE reg_getLinkTarget(RegKeyHandle hKey, + rtl_uString* linkName, + rtl_uString** pLinkTarget); + +/** This function will resolved all or only the first link of a keyname + and returns the resolved keyName in pResolvedName. + @param hKey Identifies a currently open key. + @param keyName Points to a null terminated string specifying the relativ name of a key. + The name of rKey together with keyName will be resolved from links. + If keyName is NULL the registry information under the key specified by rKey + is saved in the specified file. + @return REG_NO_ERROR if succeeds else an error code. + */ +RegError REGISTRY_CALLTYPE reg_getResolvedKeyName(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Bool firstLinkOnly, + rtl_uString** pResolvedName); + +/** This function loads registry information from a specified file and save it under the + specified keyName. + @param hKey Specifies the key where the subkey will be created. + @param keyName Points to a null terminated string specifying the name of the created subkey. + If keyName is NULL the registry information is saved under the key specified + by hKey. + @param regFileName Points to a null terminated string specifying the file containing the + registry information. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_loadKey(RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName); + + +/** This function saves the registry information from the specified key and all subkeys and save + it in the specified file. + @param hKey Identifies a currently open key. The key which inforamtion is saved by this + function is a subkey of the key identified by hKey. + @param keyName Points to a null terminated string specifying the name of the subkey. + If keyName is NULL the registry information under the key specified by hKey + is saved in the specified file. + @param regFileName Points to a null terminated string specifying the file containing the + registry information. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_saveKey(RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName); + + +/** This function merges the registry information from the specified key and the registry + information of the specified file. Existing keys will extended. + @param hKey Identifies a currently open key. The key which inforamtion is merged by this + function is a subkey of the key identified by hKey. + @param keyName Points to a null terminated string specifying the name of the subkey. + If keyName is NULL the registry information under the key specified by hKey + is merged with the information from the specified file. + @param regFileName Points to a null terminated string specifying the file containing the + registry information. + @param bWarnings if TRUE the function returns an error if a key already exists. + @param bReport if TRUE the function reports warnings on stdout if a key already exists. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_mergeKey(RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName, + sal_Bool bWarnings, + sal_Bool bReport); + + +/** This function creates a new registry with the specified name and creates a root key. + @param registryName Points to a null terminated string specifying the name of the new registry. + @param phRegistry Points to a variable that receives the handle of the created registry. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_createRegistry(rtl_uString* registryName, + RegHandle* phRegistry); + + +/** This function opens the root key of the sepcified registry. + @param hReg Identifies a currently open registry which rootKey will returned. + @param phRootKey Points to a variable that receives the handle of the open root key. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_openRootKey(RegHandle hRegistry, + RegKeyHandle* phRootKey); + + +/** This function returns the name of the registry. + @param hReg Identifies a currently open registry which name will returned. + @param pName name if succeeds else an empty string. +*/ +const RegError REGISTRY_CALLTYPE reg_getName(RegHandle hRegistry, rtl_uString** pName); + + +/** This function returns the access mode of the registry. + @param hReg Identifies a currently open registry. + @return TRUE if accessmode is read only else FALSE. +*/ +sal_Bool REGISTRY_CALLTYPE reg_isReadOnly(RegHandle hReg); + + +/** This function opens a registry with the specified name. + @param registryName Identifies a registry name. + @param phRegistry Points to a variable that receives the handle of the opened registry. + @param accessMode specify the accessmode for the registry, REG_READONLY or REG_READWRITE. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_openRegistry(rtl_uString* registryName, + RegHandle* phRegistry, + RegAccessMode accessMode); + + +/** This function close the specified registry. + @param hRegistry Identifies a currently open registry. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_closeRegistry(RegHandle hRegistry); + + +/** This function destroy the specified registry. + @param hRegistry Identifies a currently open registry. + @param registryName Identifies a registry name, if the name is NULL the registry + itselfs will be destroyed. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_destroyRegistry(RegHandle hRegistry, + rtl_uString* registryName); + + +/** This function dump the content under the open key to stdout + @param hKey Identifies a currently open key which subtree is dumped. + @return REG_NO_ERROR if succeeds else an error code. +*/ +RegError REGISTRY_CALLTYPE reg_dumpRegistry(RegKeyHandle hKey); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/registry/inc/registry/registry.hxx b/registry/inc/registry/registry.hxx new file mode 100644 index 000000000000..bc4acd25b3ad --- /dev/null +++ b/registry/inc/registry/registry.hxx @@ -0,0 +1,1220 @@ +/************************************************************************* + * + * $RCSfile: registry.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _REGISTRY_REGISTRY_HXX_ +#define _REGISTRY_REGISTRY_HXX_ + +#ifndef _REGISTRY_REGTYPE_H_ +#include <registry/regtype.h> +#endif +#ifndef _VOS_DYNLOAD_HXX_ +#include <vos/dynload.hxx> +#endif + +#ifndef _VOS_MACROS_HXX_ +#include <vos/macros.hxx> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct Registry_Api +{ + void (REGISTRY_CALLTYPE *acquire) (RegHandle); + void (REGISTRY_CALLTYPE *release) (RegHandle); + sal_Bool (REGISTRY_CALLTYPE *isReadOnly) (RegHandle); + RegError (REGISTRY_CALLTYPE *openRootKey) (RegHandle, RegKeyHandle*); + RegError (REGISTRY_CALLTYPE *getName) (RegHandle, rtl_uString**); + RegError (REGISTRY_CALLTYPE *createRegistry) (rtl_uString*, RegHandle*); + RegError (REGISTRY_CALLTYPE *openRegistry) (rtl_uString*, RegHandle*, RegAccessMode); + RegError (REGISTRY_CALLTYPE *closeRegistry) (RegHandle); + RegError (REGISTRY_CALLTYPE *destroyRegistry) (RegHandle, rtl_uString*); + RegError (REGISTRY_CALLTYPE *loadKey) (RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*); + RegError (REGISTRY_CALLTYPE *saveKey) (RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*); + RegError (REGISTRY_CALLTYPE *mergeKey) (RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*, sal_Bool, sal_Bool); + RegError (REGISTRY_CALLTYPE *dumpRegistry) (RegHandle, RegKeyHandle); + void (REGISTRY_CALLTYPE *acquireKey) (RegKeyHandle); + void (REGISTRY_CALLTYPE *releaseKey) (RegKeyHandle); + sal_Bool (REGISTRY_CALLTYPE *isKeyReadOnly) (RegKeyHandle); + RegError (REGISTRY_CALLTYPE *getKeyName) (RegKeyHandle, rtl_uString**); + RegError (REGISTRY_CALLTYPE *createKey) (RegKeyHandle, rtl_uString*, RegKeyHandle*); + RegError (REGISTRY_CALLTYPE *openKey) (RegKeyHandle, rtl_uString*, RegKeyHandle*); + RegError (REGISTRY_CALLTYPE *openSubKeys) (RegKeyHandle, rtl_uString*, RegKeyHandle**, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *closeSubKeys) (RegKeyHandle*, sal_uInt32); + RegError (REGISTRY_CALLTYPE *deleteKey) (RegKeyHandle, rtl_uString*); + RegError (REGISTRY_CALLTYPE *closeKey) (RegKeyHandle); + RegError (REGISTRY_CALLTYPE *setValue) (RegKeyHandle, rtl_uString*, RegValueType, RegValue, sal_uInt32); + RegError (REGISTRY_CALLTYPE *setLongListValue) (RegKeyHandle, rtl_uString*, sal_Int32*, sal_uInt32); + RegError (REGISTRY_CALLTYPE *setStringListValue) (RegKeyHandle, rtl_uString*, sal_Char**, sal_uInt32); + RegError (REGISTRY_CALLTYPE *setUnicodeListValue)(RegKeyHandle, rtl_uString*, sal_Unicode**, sal_uInt32); + RegError (REGISTRY_CALLTYPE *getValueInfo) (RegKeyHandle, rtl_uString*, RegValueType*, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *getValue) (RegKeyHandle, rtl_uString*, RegValue); + RegError (REGISTRY_CALLTYPE *getLongListValue) (RegKeyHandle, rtl_uString*, sal_Int32**, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *getStringListValue) (RegKeyHandle, rtl_uString*, sal_Char***, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *getUnicodeListValue)(RegKeyHandle, rtl_uString*, sal_Unicode***, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *freeValueList) (RegValueType, RegValue, sal_uInt32); + RegError (REGISTRY_CALLTYPE *createLink) (RegKeyHandle, rtl_uString*, rtl_uString*); + RegError (REGISTRY_CALLTYPE *deleteLink) (RegKeyHandle, rtl_uString*); + RegError (REGISTRY_CALLTYPE *getKeyType) (RegKeyHandle, rtl_uString*, RegKeyType*); + RegError (REGISTRY_CALLTYPE *getLinkTarget) (RegKeyHandle, rtl_uString*, rtl_uString**); + RegError (REGISTRY_CALLTYPE *getResolvedKeyName) (RegKeyHandle, rtl_uString*, sal_Bool, rtl_uString**); + RegError (REGISTRY_CALLTYPE *getKeyNames) (RegKeyHandle, rtl_uString*, rtl_uString***, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *freeKeyNames) (rtl_uString**, sal_uInt32); +}; + +typedef Registry_Api* (REGISTRY_CALLTYPE *InitRegistry_Api)(void); + +#define REGISTRY_INIT_FUNCTION_NAME "initRegistry_Api" + +#ifdef __cplusplus +} +#endif + + +class RegistryKey; + +//----------------------------------------------------------------------------- + +/** RegistryLoader load the needed DLL for the registry. + The loader can be checked if the DLL is loaded. If the DLL is loaded the + loader provides a valid Api for the registry. +*/ +class RegistryLoader : public ::vos::ODynamicLoader<Registry_Api> +{ +public: + /// Default constructor, try to load the registry DLL and initialize the needed api. + RegistryLoader() + : ::vos::ODynamicLoader<Registry_Api> + (::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("reg") ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(REGISTRY_INIT_FUNCTION_NAME) ), + sal_True, LIBRARY_VERSION, sal_False) + {} + + /// Destructor, decrease the refcount and unload the DLL if the refcount is 0. + ~RegistryLoader() + {} +}; + +/** Registry read and write information in a registry file. + Class is inline and use a load on call C-Api. +*/ +class Registry +{ +public: + /** Constructor. + This constructor is called with a valid api for the registry. + The constructor is used if the api is known. Use open() or create() + to initialize the registry with a valid registry data file. + */ + inline Registry(const Registry_Api* pApi); + + /** Constructor. + This constructor is called with a RegisterLoader for the registry. + The RegistryLoader load the needed DLL and provide the needed api for + the registry. Use open() or create() to initialize the registry with a + valid registry data file. + */ + inline Registry(const RegistryLoader& rLoader); + + /// Copy constructcor + inline Registry(const Registry& toCopy); + + /// Destructor. The Destructor close the registry if it is open. + inline ~Registry(); + + /// Assign operator + inline Registry& operator = (const Registry& toAssign); + + /// isValid checks if the registry points to a valid registry data file. + inline sal_Bool isValid() const; + + /** isReadOnly returns the access mode of the registry. + @return TRUE if accessmode is readonly else FALSE. + */ + inline sal_Bool isReadOnly() const; + + /** openRootKey opens the root key of the registry. + @param rRootKey reference on a RegistryKey which is filled with the rootkey. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError openRootKey(RegistryKey& rRootKey); + + /// getName returns the name of the current registry data file. + inline ::rtl::OUString getName(); + + /** This function creates a new registry with the specified name and creates a root key. + @param registryName specifies the name of the new registry. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError create(const ::rtl::OUString& registryName); + + /** This function opens a registry with the specified name. If the registry alreday points + to a valid registry, the old regitry will be closed. + @param registryName Identifies a registry name. + @param accessMode Specifies the accessmode for the registry, REG_READONLY or REG_READWRITE. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError open(const ::rtl::OUString& registryName, + RegAccessMode accessMode); + + /// close explicitly the current registry data file + inline RegError close(); + + /** This function destroy the specified registry. + @param registryName Identifies a registry name, if the name is an empty string the registry + itselfs will be destroyed. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError destroy(const ::rtl::OUString& registryName); + + /** This function loads registry information from a specified file and save it under the + specified keyName. + @param rKey Specifies the key where the subkey will be created. + @param keyName specifies the name of the subkey. + If keyName is an empty string the registry information is saved under the key + specified by rKey. + @param regFileName specifies the file containing the registry information. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError loadKey(RegistryKey& rKey, + const ::rtl::OUString& keyName, + const ::rtl::OUString& regFileName); + + /** This function saves the registry information from the specified key and all subkeys and save + it in the specified file. + @param rKey Identifies a currently open key. The key which inforamtion is saved by this + function is a subkey of the key identified by hKey. + @param keyName specifies the name of the subkey. + If keyName is an empty string the registry information under the key specified + by rKey is saved in the specified file. + @param regFileName specifies the file containing the registry information. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError saveKey(RegistryKey& rKey, + const ::rtl::OUString& keyName, + const ::rtl::OUString& regFileName); + + /** This function merges the registry information from the specified key and the registry + information of the specified file. Existing keys will extended. + @param rKey Identifies a currently open key. The key which inforamtion is merged by this + function is a subkey of the key identified by hKey. + @param keyName specifies the name of the subkey. + If keyName is an empty string the registry information under the key specified + by rKey is merged with the information from the specified file. + @param regFileName specifies the file containing the registry information. + @param bWarnings if TRUE the function returns an error if a key already exists. + @param bReport if TRUE the function reports warnings on stdout if a key already exists. + @return REG_NO_ERROR if succeeds else an error code. If returns an error the registry will + restore the state before merging. + */ + inline RegError mergeKey(RegistryKey& rKey, + const ::rtl::OUString& keyName, + const ::rtl::OUString& regFileName, + sal_Bool bWarnings = sal_False, + sal_Bool bReport = sal_False); + + /** This function dump the content under the open key to stdout + @param rKey Identifies a currently open key which subtree is dumped. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError dumpRegistry(RegistryKey& rKey); + + friend class RegistryKey; + friend class RegistryKeyArray; + friend class RegistryKeyNames; + + const Registry_Api* getApi() { return m_pApi; } +protected: + + const Registry_Api* m_pApi; + NAMESPACE_VOS(ODynamicLoader)<Registry_Api> m_Api; + RegHandle m_hImpl; +}; + + +//----------------------------------------------------------------------------- + +/** RegistryKeyArray presents an array of open keys. + RegistryKeyArray is a helper class to work with an array of subkeys. +*/ +class RegistryKeyArray +{ +public: + /// Default constructor + inline RegistryKeyArray(); + + /// Destructor + inline ~RegistryKeyArray(); + + /// This function returns the open key sepecified with index. + inline RegistryKey getElement(sal_uInt32 index); + + /// This function returns the length of the array. + inline sal_uInt32 getLength(); + + friend class RegistryKey; +protected: + inline void setKeyHandles(Registry& registry, RegKeyHandle* phKeys, sal_uInt32 length); + inline RegError closeKeyHandles(); + + sal_uInt32 m_length; + RegKeyHandle* m_phKeys; + Registry m_registry; +}; + + +/** RegistryKeyNames presents an array of subkey names. + RegistryKeyNames is a helper class to work with an array of subkeys. +*/ +class RegistryKeyNames +{ +public: + /// Default constructor + inline RegistryKeyNames(); + + /// Destructor + inline ~RegistryKeyNames(); + + /// This function returns the name of the key sepecified with index. + inline ::rtl::OUString getElement(sal_uInt32 index); + + /// This function returns the length of the array. + inline sal_uInt32 getLength(); + + friend class RegistryKey; +protected: + inline void setKeyNames(Registry& registry, rtl_uString** pKeyNames, sal_uInt32 length); + inline RegError freeKeyNames(); + + sal_uInt32 m_length; + rtl_uString** m_pKeyNames; + Registry m_registry; +}; + +//----------------------------------------------------------------------------- + +/** RegistryValueList presents an value list of the specified type. + RegistryValueList is a helper class to work with a list value. +*/ +template<class ValueType> +class RegistryValueList +{ +public: + /// Default constructor + RegistryValueList() + : m_length(0) + , m_pValueList(NULL) + , m_registry(NULL) + {} + + /// Destructor + ~RegistryValueList() + { + if (m_pValueList) + { + m_registry.getApi()->freeValueList(m_valueType, m_pValueList, m_length); + } + } + + /// This function returns the value of the list with the sepecified index. + ValueType getElement(sal_uInt32 index) + { + if (m_registry.isValid() && index < m_length) + { + return m_pValueList[index]; + } else + { + return 0; + } + } + + /// This function returns the length of the list. + sal_uInt32 getLength() + { + return m_length; + } + + friend class RegistryKey; +protected: + void setValueList(Registry& registry, RegValueType valueType, + ValueType* pValueList, sal_uInt32 length) + { + m_length = length; + m_pValueList = pValueList; + m_valueType = valueType; + m_registry = registry; + } + + sal_uInt32 m_length; + ValueType* m_pValueList; + RegValueType m_valueType; + Registry m_registry; +}; + +//----------------------------------------------------------------------------- + +/** RegistryKey read and write information for the specified key in a registry. + Class is inline and use a load on call C-Api. +*/ +class RegistryKey +{ +public: + /// Default constructor + inline RegistryKey(); + + /// Copy constructor + inline RegistryKey(const RegistryKey& toCopy); + + /// Destructor. The Destructor close the key if it is open. + inline ~RegistryKey(); + + /// Assign operator + inline RegistryKey& operator = (const RegistryKey& toAssign); + + /// isValid checks if the key points to a valid registry key. + inline sal_Bool isValid() const; + + /** isReadOnly returns the access mode of the key. + @return TRUE if accessmode is read only else FALSE. + */ + inline sal_Bool isReadOnly() const; + + /// getName returns the full name of the key beginning with the rootkey. + inline ::rtl::OUString getName(); + + /** This function creates the specified key. If the key already exists in the registry, + the function opens it. + @param keyName specifies the name of the key which will be opened or created. + @param rNewKey Reference a RegistryKey which will be filled with the new or open key. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError createKey(const ::rtl::OUString& keyName, + RegistryKey& rNewKey); + + /** This function opens the specified key. + @param keyName Points to a null terminated string specifying the name of a key that this + function opens. + @param rOpenKey Reference a RegistryKey which will be filled with the open key. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError openKey(const ::rtl::OUString& keyName, + RegistryKey& rOpenKey); + + /** This function returns the names of all subkeys of the key. + @param keyName Points to a null terminated string specifying the name of a key. + @param rSubKeys Reference a RegistryKeyArray which will be filled with the names of the subkeys. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError openSubKeys(const ::rtl::OUString& keyName, + RegistryKeyArray& rSubKeys); + + /** This function opens all subkeys of the key. + @param keyName Points to a null terminated string specifying the name of a key that subkeys + this function opens. + @param rSubKeyNames Reference a RegistryKeyNames array which will be filled with the open subkeys. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getKeyNames(const ::rtl::OUString& keyName, + RegistryKeyNames& rSubKeyNames); + + /** This function close all subkeys specified in the array. + @param rSubKeys Reference a RegistryKeyArray which contains the open subkeys. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError closeSubKeys(RegistryKeyArray& rSubKeys); + + /** This function deletes the specified key. + @param keyName specifies the name of the key which will be deleted. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError deleteKey(const ::rtl::OUString& keyName); + + /// close explicitly the current key + inline RegError closeKey(); + + /** This function sets an value under the key. + @param keyName specifies the name of the key which value is set by this function. + If keyName is an empty string, the value is set for the key + specified by hKey. + @param valueType Specified the type of the value. + @param pData Points to a memory block containing the current data for the value. + @param valueSize Specified the size of pData in bytes + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError setValue(const ::rtl::OUString& keyName, + RegValueType valueType, + RegValue pValue, + sal_uInt32 valueSize); + + /** This function sets an long list value under the key. + @param keyName specifies the name of the key which value is set by this function. + If keyName is an empty string, the value is set for the key + specified by hKey. + @param pValueList Points to an array of longs containing the current data for the value. + @param len Specified the len of pValueList. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError setLongListValue(const ::rtl::OUString& keyName, + sal_Int32* pValueList, + sal_uInt32 len); + + /** This function sets an ascii list value under the key. + @param keyName specifies the name of the key which value is set by this function. + If keyName is an empty string, the value is set for the key + specified by hKey. + @param pValueList Points to an array of sal_Char* containing the current data for the value. + @param len Specified the len of pValueList. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError setStringListValue(const ::rtl::OUString& keyName, + sal_Char** pValueList, + sal_uInt32 len); + + /** This function sets an unicode string list value under the key. + @param keyName specifies the name of the key which value is set by this function. + If keyName is an empty string, the value is set for the key + specified by hKey. + @param pValueList Points to an array of sal_Unicode* containing the current data for the value. + @param len Specified the len of pValueList. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError setUnicodeListValue(const ::rtl::OUString& keyName, + sal_Unicode** pValueList, + sal_uInt32 len); + + /** This function gets info about type and size of the value. + @param keyName specifies the name of the key which value is set by this function. + If keyName is an empty string, the value is set for the key + specified by hKey. + @param pValueType Specified the type of the value. + @param pValueSize Specified the size of pData in bytes or the length of a list value. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getValueInfo(const ::rtl::OUString& keyName, + RegValueType* pValueType, + sal_uInt32* pValueSize); + + /** This function gets the value under the specified key. + @param keyName specifies the name of the key which value is get by this function. + If keyName is an empty string, the value is get from the key + specified by hKey. + @param pValue Points to an allocated memory block receiving the current data for the value. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getValue(const ::rtl::OUString& keyName, + RegValue pValue); + + /** This function gets the value under the specified key. + @param keyName specifies the name of the key which value is get by this function. + If keyName is an empty string, the value is get from the key + specified by hKey. + @param rValueList Reference a RegistryValueList which will be filled with the ascii values. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getLongListValue(const ::rtl::OUString& keyName, + RegistryValueList<sal_Int32>& rValueList); + + /** This function gets the value under the specified key. + @param keyName specifies the name of the key which value is get by this function. + If keyName is an empty string, the value is get from the key + specified by hKey. + @param rValueList Reference a RegistryValueList which will be filled with the ascii values. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getStringListValue(const ::rtl::OUString& keyName, + RegistryValueList<sal_Char*>& rValueList); + + /** This function gets the value under the specified key. + @param keyName specifies the name of the key which value is get by this function. + If keyName is an empty string, the value is get from the key + specified by hKey. + @param rValueList Reference a RegistryValueList which will be filled with the unicode values. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getUnicodeListValue(const ::rtl::OUString& keyName, + RegistryValueList<sal_Unicode*>& rValueList); + + + inline RegError createLink(const ::rtl::OUString& linkName, + const ::rtl::OUString& linkTarget); + + inline RegError deleteLink(const ::rtl::OUString& linkName); + + inline RegError getKeyType(const ::rtl::OUString& name, + RegKeyType* pKeyType) const; + + inline RegError getLinkTarget(const ::rtl::OUString& linkName, + ::rtl::OUString& rLinkTarget) const; + + /** This function will resolved all or only the first link of a keyname + and returns the resolved keyName in rResolvedName. + @param keyName specifies the relativ name of the key which name will be resolved. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getResolvedKeyName(const ::rtl::OUString& keyName, + sal_Bool firstLinkOnly, + ::rtl::OUString& rResolvedName) const; + + /** getRegistryName returns the name of the current registry in which + the key is defined. + */ + inline ::rtl::OUString getRegistryName(); + + /// getRegistry returns the registry in which the key is defined. + Registry getRegistry() const { return m_registry; } + + friend class Registry; +public: + inline RegistryKey(Registry& registry, + RegKeyHandle hKey); + + RegKeyHandle getKeyHandle() const { return m_hImpl; } + +protected: + inline void setRegistry(Registry& registry); + + Registry m_registry; + RegKeyHandle m_hImpl; +}; + + +//----------------------------------------------------------------------------- + +inline RegistryKeyArray::RegistryKeyArray() + : m_length(0) + , m_phKeys(NULL) + , m_registry(NULL) +{ +} + +inline RegistryKeyArray::~RegistryKeyArray() +{ + if (m_phKeys) + m_registry.m_pApi->closeSubKeys(m_phKeys, m_length); +} + +inline RegistryKey RegistryKeyArray::getElement(sal_uInt32 index) +{ + if (m_registry.isValid() && index < m_length) + return RegistryKey(m_registry, m_phKeys[index]); + else + return RegistryKey(); +} + +inline sal_uInt32 RegistryKeyArray::getLength() +{ + return m_length; +} + +inline void RegistryKeyArray::setKeyHandles(Registry& registry, + RegKeyHandle* phKeys, + sal_uInt32 length) +{ + m_phKeys = phKeys; + m_length = length; + m_registry = registry; +} + +inline RegError RegistryKeyArray::closeKeyHandles() +{ + if (m_registry.isValid() && m_phKeys) + { + RegError ret; + ret = m_registry.m_pApi->closeSubKeys(m_phKeys, m_length); + m_registry = Registry(m_registry.m_pApi); + m_length = 0; + m_phKeys = NULL; + return ret; + } else + return(REG_INVALID_KEY); +} + +//----------------------------------------------------------------------------- + +inline RegistryKeyNames::RegistryKeyNames() + : m_length(0) + , m_pKeyNames(NULL) + , m_registry(NULL) +{ +} + +inline RegistryKeyNames::~RegistryKeyNames() +{ + if (m_pKeyNames) + m_registry.m_pApi->freeKeyNames(m_pKeyNames, m_length); +} + +inline ::rtl::OUString RegistryKeyNames::getElement(sal_uInt32 index) +{ + + if (m_pKeyNames && index < m_length) + return m_pKeyNames[index]; + else + return ::rtl::OUString(); +} + +inline sal_uInt32 RegistryKeyNames::getLength() +{ + return m_length; +} + +inline void RegistryKeyNames::setKeyNames(Registry& registry, + rtl_uString** pKeyNames, + sal_uInt32 length) +{ + m_pKeyNames = pKeyNames; + m_length = length; + m_registry = registry; +} + +inline RegError RegistryKeyNames::freeKeyNames() +{ + if (m_registry.isValid() && m_pKeyNames) + { + RegError ret = REG_NO_ERROR; + ret = m_registry.m_pApi->freeKeyNames(m_pKeyNames, m_length); + m_registry = Registry(m_registry.m_pApi); + m_length = 0; + m_pKeyNames = NULL; + return ret; + } else + return REG_INVALID_KEY; +} + +//----------------------------------------------------------------------------- + +inline RegistryKey::RegistryKey() + : m_registry(NULL) + , m_hImpl(NULL) + { } + +inline RegistryKey::RegistryKey(Registry& registry, RegKeyHandle hKey) + : m_registry(registry) + , m_hImpl(hKey) + { + if (m_hImpl) + m_registry.m_pApi->acquireKey(m_hImpl); + } + +inline RegistryKey::RegistryKey(const RegistryKey& toCopy) + : m_registry(toCopy.m_registry) + , m_hImpl(toCopy.m_hImpl) + { + if (m_hImpl) + m_registry.m_pApi->acquireKey(m_hImpl); + } + +inline void RegistryKey::setRegistry(Registry& registry) + { + m_registry = registry; + } + +inline RegistryKey::~RegistryKey() + { + if (m_hImpl) + m_registry.m_pApi->closeKey(m_hImpl); + } + +inline RegistryKey& RegistryKey::operator = (const RegistryKey& toAssign) +{ + m_registry = toAssign.m_registry; + + if (m_hImpl != toAssign.m_hImpl) + { + m_registry.m_pApi->releaseKey(m_hImpl); + m_hImpl = toAssign.m_hImpl; + m_registry.m_pApi->acquireKey(m_hImpl); + } + + return *this; +} + +inline sal_Bool RegistryKey::isValid() const + { return (m_hImpl != NULL); } + +inline sal_Bool RegistryKey::isReadOnly() const + { + if (m_registry.isValid()) + return (m_registry.m_pApi)->isKeyReadOnly(m_hImpl); + else + return sal_False; + } + +inline ::rtl::OUString RegistryKey::getName() + { + ::rtl::OUString sRet; + if (m_registry.isValid()) + m_registry.m_pApi->getKeyName(m_hImpl, &sRet.pData); + return sRet;; + } + +inline RegError RegistryKey::createKey(const ::rtl::OUString& keyName, + RegistryKey& rNewKey) + { + if (rNewKey.isValid()) rNewKey.closeKey(); + if (m_registry.isValid()) + { + RegError ret = m_registry.m_pApi->createKey(m_hImpl, keyName.pData, &rNewKey.m_hImpl); + if (!ret) rNewKey.setRegistry(m_registry); + return ret; + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::openKey(const ::rtl::OUString& keyName, + RegistryKey& rOpenKey) + { + if (rOpenKey.isValid()) rOpenKey.closeKey(); + if (m_registry.isValid()) + { + RegError ret = m_registry.m_pApi->openKey(m_hImpl, keyName.pData, + &rOpenKey.m_hImpl); + if (!ret) rOpenKey.setRegistry(m_registry); + return ret; + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::openSubKeys(const ::rtl::OUString& keyName, + RegistryKeyArray& rSubKeys) + { + if (m_registry.isValid()) + { + RegError ret = REG_NO_ERROR; + RegKeyHandle* pSubKeys; + sal_uInt32 nSubKeys; + if (ret = m_registry.m_pApi->openSubKeys(m_hImpl, keyName.pData, + &pSubKeys, &nSubKeys)) + { + return ret; + } else + { + rSubKeys.setKeyHandles(m_registry, pSubKeys, nSubKeys); + return ret; + } + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getKeyNames(const ::rtl::OUString& keyName, + RegistryKeyNames& rSubKeyNames) + { + if (m_registry.isValid()) + { + RegError ret = REG_NO_ERROR; + rtl_uString** pSubKeyNames; + sal_uInt32 nSubKeys; + if (ret = m_registry.m_pApi->getKeyNames(m_hImpl, keyName.pData, + &pSubKeyNames, &nSubKeys)) + { + return ret; + } else + { + rSubKeyNames.setKeyNames(m_registry, pSubKeyNames, nSubKeys); + return ret; + } + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::closeSubKeys(RegistryKeyArray& rSubKeys) + { + if (m_registry.isValid()) + return rSubKeys.closeKeyHandles(); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::deleteKey(const ::rtl::OUString& keyName) + { + if (m_registry.isValid()) + return m_registry.m_pApi->deleteKey(m_hImpl, keyName.pData); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::closeKey() + { + if (m_registry.isValid()) + { + RegError ret = m_registry.m_pApi->closeKey(m_hImpl); + if (!ret) + { + m_hImpl = NULL; + m_registry = Registry(m_registry.m_pApi); + } + return ret; + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::setValue(const ::rtl::OUString& keyName, + RegValueType valueType, + RegValue pValue, + sal_uInt32 valueSize) + { + if (m_registry.isValid()) + return m_registry.m_pApi->setValue(m_hImpl, keyName.pData, valueType, + pValue, valueSize); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::setLongListValue(const ::rtl::OUString& keyName, + sal_Int32* pValueList, + sal_uInt32 len) + { + if (m_registry.isValid()) + return m_registry.m_pApi->setLongListValue(m_hImpl, keyName.pData, + pValueList, len); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::setStringListValue(const ::rtl::OUString& keyName, + sal_Char** pValueList, + sal_uInt32 len) + { + if (m_registry.isValid()) + return m_registry.m_pApi->setStringListValue(m_hImpl, keyName.pData, + pValueList, len); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::setUnicodeListValue(const ::rtl::OUString& keyName, + sal_Unicode** pValueList, + sal_uInt32 len) + { + if (m_registry.isValid()) + return m_registry.m_pApi->setUnicodeListValue(m_hImpl, keyName.pData, + pValueList, len); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getValueInfo(const ::rtl::OUString& keyName, + RegValueType* pValueType, + sal_uInt32* pValueSize) + { + if (m_registry.isValid()) + return m_registry.m_pApi->getValueInfo(m_hImpl, keyName.pData, pValueType, pValueSize); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getValue(const ::rtl::OUString& keyName, + RegValue pValue) + { + if (m_registry.isValid()) + return m_registry.m_pApi->getValue(m_hImpl, keyName.pData, pValue); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getLongListValue(const ::rtl::OUString& keyName, + RegistryValueList<sal_Int32>& rValueList) + { + if (m_registry.isValid()) + { + RegError ret = REG_NO_ERROR; + sal_Int32* pValueList; + sal_uInt32 length; + if (ret = m_registry.m_pApi->getLongListValue(m_hImpl, keyName.pData, + &pValueList, &length)) + { + return ret; + } else + { + rValueList.setValueList(m_registry, RG_VALUETYPE_LONGLIST, + pValueList, length); + return ret; + } + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getStringListValue(const ::rtl::OUString& keyName, + RegistryValueList<sal_Char*>& rValueList) + { + if (m_registry.isValid()) + { + RegError ret = REG_NO_ERROR; + sal_Char** pValueList; + sal_uInt32 length; + if (ret = m_registry.m_pApi->getStringListValue(m_hImpl, keyName.pData, + &pValueList, &length)) + { + return ret; + } else + { + rValueList.setValueList(m_registry, RG_VALUETYPE_STRINGLIST, + pValueList, length); + return ret; + } + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getUnicodeListValue(const ::rtl::OUString& keyName, + RegistryValueList<sal_Unicode*>& rValueList) + { + if (m_registry.isValid()) + { + RegError ret = REG_NO_ERROR; + sal_Unicode** pValueList; + sal_uInt32 length; + if (ret = m_registry.m_pApi->getUnicodeListValue(m_hImpl, keyName.pData, + &pValueList, &length)) + { + return ret; + } else + { + rValueList.setValueList(m_registry, RG_VALUETYPE_UNICODELIST, + pValueList, length); + return ret; + } + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::createLink(const ::rtl::OUString& linkName, + const ::rtl::OUString& linkTarget) + { + if (m_registry.isValid()) + return m_registry.m_pApi->createLink(m_hImpl, linkName.pData, linkTarget.pData); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::deleteLink(const ::rtl::OUString& linkName) + { + if (m_registry.isValid()) + return m_registry.m_pApi->deleteLink(m_hImpl, linkName.pData); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getKeyType(const ::rtl::OUString& keyName, + RegKeyType* pKeyType) const + { + if (m_registry.isValid()) + return m_registry.m_pApi->getKeyType(m_hImpl, keyName.pData, pKeyType); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getLinkTarget(const ::rtl::OUString& linkName, + ::rtl::OUString& rLinkTarget) const + { + if (m_registry.isValid()) + { + return m_registry.m_pApi->getLinkTarget(m_hImpl, + linkName.pData, + &rLinkTarget.pData); + } else + return REG_INVALID_KEY; + } + + +inline RegError RegistryKey::getResolvedKeyName(const ::rtl::OUString& keyName, + sal_Bool firstLinkOnly, + ::rtl::OUString& rResolvedName) const + { + if (m_registry.isValid()) + return m_registry.m_pApi->getResolvedKeyName(m_hImpl, + keyName.pData, + firstLinkOnly, + &rResolvedName.pData); + else + return REG_INVALID_KEY; + } + +inline ::rtl::OUString RegistryKey::getRegistryName() + { + if (m_registry.isValid()) + { + return m_registry.getName(); + } else + return ::rtl::OUString(); + } + +//----------------------------------------------------------------------------- + +inline Registry::Registry(const Registry_Api* pApi) + : m_pApi(pApi) + , m_Api() + , m_hImpl(NULL) + { } + +inline Registry::Registry(const RegistryLoader& rLoader) + : m_pApi(NULL) + , m_Api(rLoader) + , m_hImpl(NULL) + { + m_pApi = m_Api.getApi(); + } + +inline Registry::Registry(const Registry& toCopy) + : m_pApi(toCopy.m_pApi) + , m_Api(toCopy.m_Api) + , m_hImpl(toCopy.m_hImpl) + { + if (m_hImpl) + m_pApi->acquire(m_hImpl); + } + + +inline Registry::~Registry() + { + if (m_pApi && m_hImpl) + m_pApi->release(m_hImpl); + } + +inline Registry& Registry::operator = (const Registry& toAssign) +{ + + if (m_hImpl != toAssign.m_hImpl) + { + if (m_pApi) m_pApi->release(m_hImpl); + m_pApi = toAssign.m_pApi; + m_Api = toAssign.m_Api; + m_hImpl = toAssign.m_hImpl; + } + if (m_hImpl && m_pApi) + m_pApi->acquire(m_hImpl); + + return *this; +} + +inline sal_Bool Registry::isValid() const + { return ( m_hImpl != NULL && m_pApi != NULL ); } + +inline sal_Bool Registry::isReadOnly() const + { return m_pApi->isReadOnly(m_hImpl); } + +inline RegError Registry::openRootKey(RegistryKey& rRootKey) + { + rRootKey.setRegistry(*this); + return m_pApi->openRootKey(m_hImpl, &rRootKey.m_hImpl); + } + +inline ::rtl::OUString Registry::getName() + { + ::rtl::OUString sRet; + m_pApi->getName(m_hImpl, &sRet.pData); + return sRet; + } + +inline RegError Registry::create(const ::rtl::OUString& registryName) + { + if (m_hImpl) + m_pApi->release(m_hImpl); + return m_pApi->createRegistry(registryName.pData, &m_hImpl); + } + +inline RegError Registry::open(const ::rtl::OUString& registryName, + RegAccessMode accessMode) + { + if (m_hImpl) + m_pApi->release(m_hImpl); + return m_pApi->openRegistry(registryName.pData, &m_hImpl, accessMode); + } + +inline RegError Registry::close() + { + RegError ret = m_pApi->closeRegistry(m_hImpl); + if (!ret) + m_hImpl = NULL; + return ret; + } + +inline RegError Registry::destroy(const ::rtl::OUString& registryName) + { + RegError ret = m_pApi->destroyRegistry(m_hImpl, registryName.pData); + if ( !ret && (registryName.getLength() == 0) ) + m_hImpl = NULL; + return ret; + } + +inline RegError Registry::loadKey(RegistryKey& rKey, + const ::rtl::OUString& keyName, + const ::rtl::OUString& regFileName) + { return m_pApi->loadKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData); } + +inline RegError Registry::saveKey(RegistryKey& rKey, + const ::rtl::OUString& keyName, + const ::rtl::OUString& regFileName) + { return m_pApi->saveKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData); } + +inline RegError Registry::mergeKey(RegistryKey& rKey, + const ::rtl::OUString& keyName, + const ::rtl::OUString& regFileName, + sal_Bool bWarnings, + sal_Bool bReport) + { return m_pApi->mergeKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData, bWarnings, bReport); } + +inline RegError Registry::dumpRegistry(RegistryKey& rKey) + { return m_pApi->dumpRegistry(m_hImpl, rKey.m_hImpl); } + + +#endif diff --git a/registry/inc/registry/regtype.h b/registry/inc/registry/regtype.h new file mode 100644 index 000000000000..42f8643e3fa7 --- /dev/null +++ b/registry/inc/registry/regtype.h @@ -0,0 +1,185 @@ +/************************************************************************* + * + * $RCSfile: regtype.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _REGISTRY_REGTYPE_H_ +#define _REGISTRY_REGTYPE_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +// version number of the library. This number is used for the load on call +// mechanism and must be modifed when the library will be upgraded to a new version. +#define LIBRARY_VERSION 2 + +typedef void* RegHandle; + +typedef void* RegKeyHandle; + +typedef void* RegValue; + +typedef sal_uInt16 RegAccessMode; + +#define REG_READONLY 0x0001 // allow read accesses only +#define REG_READWRITE 0x0002 // allow read and write accesses + +/// RegKeyType specify the type of the key, if it is a real key or a link +enum RegKeyType +{ + /// The key is a real key + RG_KEYTYPE, + /// The key is a link + RG_LINKTYPE +}; + +/// RegValueType specify the type of the value of a key +enum RegValueType +{ + /// The key has no value + RG_VALUETYPE_NOT_DEFINED, + /// The key has a value of type long + RG_VALUETYPE_LONG, + /// The key has a value of type ascii + RG_VALUETYPE_STRING, + /// The key has a value of type unicode + RG_VALUETYPE_UNICODE, + /// The key has a value of type binary + RG_VALUETYPE_BINARY, + /// The key has a value of type long list + RG_VALUETYPE_LONGLIST, + /// The key has a value of type ascii list + RG_VALUETYPE_STRINGLIST, + /// The key has a value of type unicode list + RG_VALUETYPE_UNICODELIST +}; + +/// RegError specify the possible error codes +enum RegError +{ + /// no error + REG_NO_ERROR, + /// internal registry error + REG_INTERNAL_ERROR, + + /// registry is not open + REG_REGISTRY_NOT_OPEN, + /// registry does not exists + REG_REGISTRY_NOT_EXISTS, + /// registry is readonly + REG_REGISTRY_READONLY, + /// destroy registry failed. Ther are may be any open keys. + REG_DESTROY_REGISTRY_FAILED, + /** registry cannot open for readwrite because the registry is already + open for readwrite anywhere. + */ + REG_CANNOT_OPEN_FOR_READWRITE, + /** registry is in a invalid state or the registry does not point to + a valid registry data file + */ + REG_INVALID_REGISTRY, + + /// The key is not open + REG_KEY_NOT_OPEN, + /// The key not exists + REG_KEY_NOT_EXISTS, + /// The key cannot created + REG_CREATE_KEY_FAILED, + /// The key cannot not deleted + REG_DELETE_KEY_FAILED, + /** The keyname is invalid. This error will return if the keyname + is NULL but should not be NULL in the context of called function. + */ + REG_INVALID_KEYNAME, + /// The key is not in a valid state + REG_INVALID_KEY, + + /// key has no value + REG_VALUE_NOT_EXISTS, + /// + REG_SET_VALUE_FAILED, + /// + REG_DELETE_VALUE_FAILED, + /// + REG_INVALID_VALUE, + + /// + REG_MERGE_ERROR, + /// + REG_MERGE_CONFLICT, + + /// + REG_DETECT_RECURSION, + /// + REG_INVALID_LINK, + /// + REG_INVALID_LINKNAME, + /// + REG_INVALID_LINKTARGET, + /// + REG_LINKTARGET_NOT_EXIST, + /// + REG_BUFFERSIZE_TOSMALL +}; + + +#define REGISTRY_CALLTYPE SAL_CALL + +#endif diff --git a/registry/prj/d.lst b/registry/prj/d.lst new file mode 100644 index 000000000000..e3086d058171 --- /dev/null +++ b/registry/prj/d.lst @@ -0,0 +1,20 @@ +dos: mkdir %_DEST%\inc%_EXT%\registry +mkdir: %_DEST%\lib%_EXT%\libreg2.dylib.framework + +..\inc\registry\*.h %_DEST%\inc%_EXT%\registry\*.h +..\inc\registry\*.hxx %_DEST%\inc%_EXT%\registry\*.hxx + +..\%__SRC%\lib\ireg.lib %_DEST%\lib%_EXT%\ireg.lib +..\%__SRC%\lib\libreg*.so %_DEST%\lib%_EXT%\libreg*.so +..\%__SRC%\lib\libreg*.so.* %_DEST%\lib%_EXT%\libreg*.so.* +..\%__SRC%\bin\reg*.dll %_DEST%\bin%_EXT%\reg*.dll +..\%__SRC%\lib\libreg*.dylib %_DEST%\lib%_EXT%\libreg*.dylib +..\%__SRC%\lib\libreg2.dylib.framework\libreg*.dylib %_DEST%\lib%_EXT%\libreg2.dylib.framework\libreg*.dylib + +..\%__SRC%\bin\regmerge.exe %_DEST%\bin%_EXT%\regmerge.exe +..\%__SRC%\bin\regview.exe %_DEST%\bin%_EXT%\regview.exe +..\%__SRC%\bin\regmerge %_DEST%\bin%_EXT%\regmerge +..\%__SRC%\bin\regview %_DEST%\bin%_EXT%\regview +..\version.mk %_DEST%\inc%_EXT%\registry\version.mk + + diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx new file mode 100644 index 000000000000..88ab180472c7 --- /dev/null +++ b/registry/source/keyimpl.cxx @@ -0,0 +1,1260 @@ +/************************************************************************* + * + * $RCSfile: keyimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef __REFLCNST_HXX__ +#include "reflcnst.hxx" +#endif + +#include "keyimpl.hxx" + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + +#ifndef _RTL_MEMORY_H_ +#include <rtl/memory.h> +#endif + +//********************************************************************* +// ORegKey() +// +ORegKey::ORegKey(const OUString& keyName, const OStoreDirectory& rStoreDir, ORegistry* pReg) + : m_refCount(1) + , m_name(keyName) + , m_bDeleted(sal_False) + , m_isLink(sal_False) + , m_pRegistry(pReg) +{ + if (pReg) + { + m_storeFile = pReg->getStoreFile(); + } + + checkLink(); +} + +//********************************************************************* +// ORegKey() +// +ORegKey::ORegKey(const OUString& keyName, const OUString& linkName, + const OStoreDirectory& rStoreDir, ORegistry* pReg) + : m_refCount(1) + , m_name(keyName) + , m_bDeleted(sal_False) + , m_pRegistry(pReg) +{ + if (linkName.getLength()) + { + m_link = linkName; + m_isLink = sal_True; + + setValue(OUString( RTL_CONSTASCII_USTRINGPARAM("LINK_TARGET") ), RG_VALUETYPE_UNICODE, + (RegValue*)linkName.pData->buffer, linkName.getLength()+1); + } else + { + m_isLink = sal_False; + } +} + +//********************************************************************* +// ORegKey() +// +ORegKey::ORegKey() + : m_refCount(1) + , m_bDeleted(sal_False) + , m_isLink(sal_False) + , m_pRegistry(NULL) +{ +} + + +//********************************************************************* +// ~ORegKey() +// +ORegKey::~ORegKey() +{ +} + + +//********************************************************************* +// createKey +// +RegError ORegKey::createKey(const OUString& keyName, RegKeyHandle* phNewKey) +{ + return m_pRegistry->createKey(this, keyName, phNewKey); +} + + +//********************************************************************* +// openKey +// +RegError ORegKey::openKey(const OUString& keyName, RegKeyHandle* phOpenKey, RESOLVE eResolve) +{ + return (m_pRegistry->openKey(this, keyName, phOpenKey, eResolve)); +} + + +//********************************************************************* +// openSubKeys +// +RegError ORegKey::openSubKeys(const OUString& keyName, RegKeyHandle** phOpenSubKeys, sal_uInt32* pnSubKeys) +{ + ORegKey* pKey; + OUString sFullKeyName, sSubKeyName; + RegKeyHandle hSKey, hSubKey; + RegError _ret = REG_NO_ERROR; + sal_uInt32 nSubKeys; + ORegKey* *subKeys; + + if ( keyName.getLength() ) + { + if ((_ret = openKey(keyName, &hSKey))) + { + *phOpenSubKeys = NULL; + *pnSubKeys = 0; + return _ret; + } + + pKey = (ORegKey*)hSKey; + } else + { + pKey = this; + } + + nSubKeys = pKey->countSubKeys(); + + *pnSubKeys = nSubKeys; + subKeys = (ORegKey**)rtl_allocateZeroMemory(nSubKeys * sizeof(ORegKey*)); + + OStoreDirectory::iterator iter; + OStoreDirectory rStoreDir(pKey->getStoreDir()); + storeError _err = rStoreDir.first(iter); + + nSubKeys = 0; + while ( _err == store_E_None ) + { + if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR ) + { + sSubKeyName = iter.m_pszName; + sFullKeyName = pKey->getName(); + if (sFullKeyName.getLength() > 1) + sFullKeyName += m_pRegistry->ROOT; + sFullKeyName += sSubKeyName; + + if (_ret = pKey->openKey(sSubKeyName, &hSubKey)) + { + *phOpenSubKeys = NULL; + *pnSubKeys = 0; + rtl_freeMemory(subKeys); + return _ret; + } + + subKeys[nSubKeys] = ((ORegKey*)hSubKey); + + nSubKeys++; + } + + _err = rStoreDir.next(iter); + } + + *phOpenSubKeys = (RegKeyHandle*)subKeys; + if (keyName.getLength()) + { + closeKey(hSKey); + } + return REG_NO_ERROR; +} + + +//********************************************************************* +// getKeyNames +// +RegError ORegKey::getKeyNames(const OUString& keyName, + rtl_uString*** pSubKeyNames, + sal_uInt32* pnSubKeys) +{ + ORegKey* pKey; + OUString sFullKeyName, sSubKeyName; + RegError _ret = REG_NO_ERROR; + sal_uInt32 nSubKeys; + rtl_uString** pSubKeys; + + if (keyName.getLength()) + { + if (_ret = openKey(keyName, (RegKeyHandle*)&pKey, RESOLVE_PART)) + { + *pSubKeyNames = NULL; + *pnSubKeys = 0; + return _ret; + } + } else + { + pKey = this; + } + + nSubKeys = pKey->countSubKeys(); + + *pnSubKeys = nSubKeys; + pSubKeys = (rtl_uString**)rtl_allocateZeroMemory(nSubKeys * sizeof(rtl_uString*)); + + OStoreDirectory::iterator iter; + OStoreDirectory rStoreDir(pKey->getStoreDir()); + storeError _err = rStoreDir.first(iter); + OUString subKey; + + nSubKeys = 0; + + while ( _err == store_E_None ) + { + if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR) + { + sSubKeyName = iter.m_pszName; + sFullKeyName = pKey->getName(); + if (sFullKeyName.getLength() > 1) + sFullKeyName += m_pRegistry->ROOT; + sFullKeyName += sSubKeyName; + + subKey = sFullKeyName; + rtl_uString_newFromString(&pSubKeys[nSubKeys], subKey.pData); + + nSubKeys++; + } + + _err = rStoreDir.next(iter); + } + + *pSubKeyNames = pSubKeys; + if (keyName.getLength()) + { + closeKey((RegKeyHandle)pKey); + } + return REG_NO_ERROR; +} + + +//********************************************************************* +// closeSubKeys +// +RegError ORegKey::closeSubKeys(RegKeyHandle* phSubKeys, sal_uInt32 nSubKeys) +{ + RegError _ret = REG_NO_ERROR; + + for (int i=0; i < nSubKeys; i++) + { + _ret = closeKey(phSubKeys[i]); + } + + rtl_freeMemory(phSubKeys); + return _ret; +} + + +//********************************************************************* +// closeKey +// +RegError ORegKey::closeKey(RegKeyHandle hKey) +{ + return (m_pRegistry->closeKey(hKey)); +} + + +//********************************************************************* +// deleteKey +// +RegError ORegKey::deleteKey(const OUString& keyName) +{ + return (m_pRegistry->deleteKey(this, keyName)); +} + + +//********************************************************************* +// getValueType +// +RegError ORegKey::getValueInfo(const OUString& valueName, RegValueType* pValueType, sal_uInt32* pValueSize) const +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + storeAccessMode accessMode = VALUE_MODE_OPEN; + + if (m_pRegistry->isReadOnly()) + { + accessMode = VALUE_MODE_OPENREAD; + } + + OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); + sImplValueName += valueName; + + REG_GUARD(m_pRegistry->m_mutex); + + if ( rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) + { + *pValueType = RG_VALUETYPE_NOT_DEFINED; + *pValueSize = 0; + return REG_VALUE_NOT_EXISTS; + } + + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); + + sal_uInt32 readBytes; + if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) ) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (readBytes != VALUE_HEADERSIZE) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + sal_uInt32 size; + sal_uInt8 type = *((sal_uInt8*)pBuffer); + readUINT32(pBuffer+VALUE_TYPEOFFSET, size); + + *pValueType = (RegValueType)type; +// if (*pValueType == RG_VALUETYPE_UNICODE) +// { +// *pValueSize = (size / 2) * sizeof(sal_Unicode); +// } else +// { + if (*pValueType > 4) + { + rtl_freeMemory(pBuffer); + pBuffer = (sal_uInt8*)rtl_allocateMemory(4); + rValue.readAt(VALUE_HEADEROFFSET, pBuffer, 4, readBytes); + + readUINT32(pBuffer, size); + } + + *pValueSize = size; +// } + + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; +} + + +//********************************************************************* +// setValue +// +RegError ORegKey::setValue(const OUString& valueName, RegValueType vType, RegValue value, sal_uInt32 vSize) +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + + if (m_pRegistry->isReadOnly()) + { + return REG_REGISTRY_READONLY; + } + + if (vType > 4) + { + return REG_INVALID_VALUE; + } + + OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); + sImplValueName += valueName; + + REG_GUARD(m_pRegistry->m_mutex); + + if ( rValue.create(m_storeFile, m_name + m_pRegistry->ROOT , sImplValueName, VALUE_MODE_CREATE) ) + { + return REG_SET_VALUE_FAILED; + } + + sal_uInt32 size = vSize; + +// if (vType == RG_VALUETYPE_UNICODE) +// { +// size = (rtl_ustr_getLength((sal_Unicode*)value)+1) * 2; +// } + + sal_uInt8 type = (sal_uInt8)vType; + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE + size); + rtl_copyMemory(pBuffer, &type, 1); + + writeUINT32(pBuffer+VALUE_TYPEOFFSET, size); + + switch (vType) + { + case RG_VALUETYPE_NOT_DEFINED: + rtl_copyMemory(pBuffer+VALUE_HEADEROFFSET, value, size); + break; + case RG_VALUETYPE_LONG: + writeINT32(pBuffer+VALUE_HEADEROFFSET, *((sal_Int32*)value)); + break; + case RG_VALUETYPE_STRING: + writeUtf8(pBuffer+VALUE_HEADEROFFSET, (const sal_Char*)value); + break; + case RG_VALUETYPE_UNICODE: + writeString(pBuffer+VALUE_HEADEROFFSET, (const sal_Unicode*)value); + break; + case RG_VALUETYPE_BINARY: + rtl_copyMemory(pBuffer+VALUE_HEADEROFFSET, value, size); + break; + } + + + sal_uInt32 writenBytes; + if ( rValue.writeAt(0, pBuffer, VALUE_HEADERSIZE+size, writenBytes) ) + { + rtl_freeMemory(pBuffer); + return REG_SET_VALUE_FAILED; + } + if (writenBytes != (VALUE_HEADERSIZE+size)) + { + rtl_freeMemory(pBuffer); + return REG_SET_VALUE_FAILED; + } + + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; +} + +//********************************************************************* +// setLongListValue +// +RegError ORegKey::setLongListValue(const OUString& valueName, sal_Int32* pValueList, sal_uInt32 len) +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + + if (m_pRegistry->isReadOnly()) + { + return REG_REGISTRY_READONLY; + } + + OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); + sImplValueName += valueName; + + REG_GUARD(m_pRegistry->m_mutex); + + if (rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) ) + { + return REG_SET_VALUE_FAILED; + } + + sal_uInt32 size = 4; // 4 Bytes (sal_uInt32) fuer die Laenge + + size += len * 4; + + sal_uInt8 type = (sal_uInt8)RG_VALUETYPE_LONGLIST; + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE + size); + rtl_copyMemory(pBuffer, &type, 1); + + writeUINT32(pBuffer+VALUE_TYPEOFFSET, size); + writeUINT32(pBuffer+VALUE_HEADEROFFSET, len); + + sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays + + for (int i=0; i < len; i++) + { + writeINT32(pBuffer+VALUE_HEADEROFFSET+offset, pValueList[i]); + offset += 4; + } + + sal_uInt32 writenBytes; + if ( rValue.writeAt(0, pBuffer, VALUE_HEADERSIZE+size, writenBytes) ) + { + rtl_freeMemory(pBuffer); + return REG_SET_VALUE_FAILED; + } + if (writenBytes != (VALUE_HEADEROFFSET+size)) + { + rtl_freeMemory(pBuffer); + return REG_SET_VALUE_FAILED; + } + + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; +} + +//********************************************************************* +// setStringListValue +// +RegError ORegKey::setStringListValue(const OUString& valueName, sal_Char** pValueList, sal_uInt32 len) +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + + if (m_pRegistry->isReadOnly()) + { + return REG_REGISTRY_READONLY; + } + + OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); + sImplValueName += valueName; + + REG_GUARD(m_pRegistry->m_mutex); + + if (rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) ) + { + return REG_SET_VALUE_FAILED; + } + + sal_uInt32 size = 4; // 4 Bytes (sal_uInt32) fuer die Laenge + + int i; + for (i=0; i < len; i++) + { + size += 4 + strlen(pValueList[i]) + 1; + } + + sal_uInt8 type = (sal_uInt8)RG_VALUETYPE_STRINGLIST; + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE + size); + rtl_copyMemory(pBuffer, &type, 1); + + writeUINT32(pBuffer+VALUE_TYPEOFFSET, size); + writeUINT32(pBuffer+VALUE_HEADEROFFSET, len); + + sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays; + sal_uInt32 sLen = 0; + + for (i=0; i < len; i++) + { + sLen = strlen(pValueList[i]) + 1; + writeUINT32(pBuffer+VALUE_HEADEROFFSET+offset, sLen); + + offset += 4; + writeUtf8(pBuffer+VALUE_HEADEROFFSET+offset, pValueList[i]); + offset += sLen; + } + + sal_uInt32 writenBytes; + if ( rValue.writeAt(0, pBuffer, VALUE_HEADERSIZE+size, writenBytes) ) + { + rtl_freeMemory(pBuffer); + return REG_SET_VALUE_FAILED; + } + if (writenBytes != (VALUE_HEADERSIZE+size)) + { + rtl_freeMemory(pBuffer); + return REG_SET_VALUE_FAILED; + } + + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; +} + +//********************************************************************* +// setUnicodeListValue +// +RegError ORegKey::setUnicodeListValue(const OUString& valueName, sal_Unicode** pValueList, sal_uInt32 len) +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + + if (m_pRegistry->isReadOnly()) + { + return REG_REGISTRY_READONLY; + } + + OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); + sImplValueName += valueName; + + REG_GUARD(m_pRegistry->m_mutex); + + if (rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, VALUE_MODE_CREATE) ) + { + return REG_SET_VALUE_FAILED; + } + + sal_uInt32 size = 4; // 4 Bytes (sal_uInt32) fuer die Laenge + + int i; + for (i=0; i < len; i++) + { + size += 4 + ((rtl_ustr_getLength(pValueList[i]) +1) * 2); + } + + sal_uInt8 type = (sal_uInt8)RG_VALUETYPE_UNICODELIST; + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE + size); + rtl_copyMemory(pBuffer, &type, 1); + + writeUINT32(pBuffer+VALUE_TYPEOFFSET, size); + writeUINT32(pBuffer+VALUE_HEADEROFFSET, len); + + sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays; + sal_uInt32 sLen = 0; + + for (i=0; i < len; i++) + { + sLen = (rtl_ustr_getLength(pValueList[i]) + 1) * 2; + writeUINT32(pBuffer+VALUE_HEADEROFFSET+offset, sLen); + + offset += 4; + writeString(pBuffer+VALUE_HEADEROFFSET+offset, pValueList[i]); + offset += sLen; + } + + sal_uInt32 writenBytes; + if ( rValue.writeAt(0, pBuffer, VALUE_HEADERSIZE+size, writenBytes) ) + { + rtl_freeMemory(pBuffer); + return REG_SET_VALUE_FAILED; + } + if (writenBytes != (VALUE_HEADERSIZE+size)) + { + rtl_freeMemory(pBuffer); + return REG_SET_VALUE_FAILED; + } + + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; +} + +//********************************************************************* +// getValue +// +RegError ORegKey::getValue(const OUString& valueName, RegValue value) const +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + RegValueType valueType; + sal_uInt32 valueSize; + storeAccessMode accessMode = VALUE_MODE_OPEN; + + if (m_pRegistry->isReadOnly()) + { + accessMode = VALUE_MODE_OPENREAD; + } + + OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); + sImplValueName += valueName; + + REG_GUARD(m_pRegistry->m_mutex); + + if (rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) + { + return REG_VALUE_NOT_EXISTS; + } + + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); + + sal_uInt32 readBytes; + if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) ) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (readBytes != VALUE_HEADERSIZE) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + sal_uInt8 type = *((sal_uInt8*)pBuffer); + valueType = (RegValueType)type; + readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize); + + rtl_freeMemory(pBuffer); + + if (valueType > 4) + { + return REG_INVALID_VALUE; + } + + pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize); + + if ( rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, readBytes) ) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (readBytes != valueSize) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + +// rtl_copyMemory(value, pBuffer, valueSize); + switch (valueType) + { + case RG_VALUETYPE_NOT_DEFINED: + rtl_copyMemory(value, pBuffer, valueSize); + break; + case RG_VALUETYPE_LONG: + readINT32(pBuffer, *((sal_Int32*)value)); + break; + case RG_VALUETYPE_STRING: + readUtf8(pBuffer, (sal_Char*)value, valueSize); + break; + case RG_VALUETYPE_UNICODE: + readString(pBuffer, (sal_Unicode*)value, valueSize); + break; + case RG_VALUETYPE_BINARY: + rtl_copyMemory(value, pBuffer, valueSize); + break; + case RG_VALUETYPE_LONGLIST: + case RG_VALUETYPE_STRINGLIST: + case RG_VALUETYPE_UNICODELIST: + rtl_copyMemory(value, pBuffer, valueSize); + break; + } + + + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; +} + +//********************************************************************* +// getLongListValue +// +RegError ORegKey::getLongListValue(const OUString& valueName, sal_Int32** pValueList, sal_uInt32* pLen) const +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + RegValueType valueType; + sal_uInt32 valueSize; + storeAccessMode accessMode = VALUE_MODE_OPEN; + + if (m_pRegistry->isReadOnly()) + { + accessMode = VALUE_MODE_OPENREAD; + } + + OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); + sImplValueName += valueName; + + REG_GUARD(m_pRegistry->m_mutex); + + if (rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) + { + pValueList = NULL; + *pLen = 0; + return REG_VALUE_NOT_EXISTS; + } + + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); + + sal_uInt32 readBytes; + if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) ) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (readBytes != VALUE_HEADERSIZE) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + sal_uInt8 type = *((sal_uInt8*)pBuffer); + valueType = (RegValueType)type; + + if (valueType != RG_VALUETYPE_LONGLIST) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize); + + rtl_freeMemory(pBuffer); + + pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize); + + if ( rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, readBytes) ) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (readBytes != valueSize) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + sal_uInt32 len = 0; + readUINT32(pBuffer, len); + + *pLen = len; + sal_Int32* pVList = (sal_Int32*)rtl_allocateZeroMemory(len * sizeof(sal_Int32)); + + sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays; + + for (int i=0; i < len; i++) + { + readINT32(pBuffer+offset, pVList[i]); + offset += 4; + } + + *pValueList = pVList; + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; +} + +//********************************************************************* +// getStringListValue +// +RegError ORegKey::getStringListValue(const OUString& valueName, sal_Char*** pValueList, sal_uInt32* pLen) const +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + RegValueType valueType; + sal_uInt32 valueSize; + storeAccessMode accessMode = VALUE_MODE_OPEN; + + if (m_pRegistry->isReadOnly()) + { + accessMode = VALUE_MODE_OPENREAD; + } + + OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); + sImplValueName += valueName; + + REG_GUARD(m_pRegistry->m_mutex); + + if ( rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) + { + pValueList = NULL; + *pLen = 0; + return REG_VALUE_NOT_EXISTS; + } + + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); + + sal_uInt32 readBytes; + if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) ) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (readBytes != VALUE_HEADERSIZE) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + sal_uInt8 type = *((sal_uInt8*)pBuffer); + valueType = (RegValueType)type; + + if (valueType != RG_VALUETYPE_STRINGLIST) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize); + + rtl_freeMemory(pBuffer); + + pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize); + + if ( rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, readBytes) ) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (readBytes != valueSize) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + sal_uInt32 len = 0; + readUINT32(pBuffer, len); + + *pLen = len; + sal_Char** pVList = (sal_Char**)rtl_allocateZeroMemory(len * sizeof(sal_Char*)); + + sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays; + sal_uInt32 sLen = 0; + + sal_Char *pValue; + for (int i=0; i < len; i++) + { + readUINT32(pBuffer+offset, sLen); + + offset += 4; + + pValue = (sal_Char*)rtl_allocateMemory(sLen); + readUtf8(pBuffer+offset, pValue, sLen); + pVList[i] = pValue; + + offset += sLen; + } + + *pValueList = pVList; + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; +} + +//********************************************************************* +// getUnicodeListValue +// +RegError ORegKey::getUnicodeListValue(const OUString& valueName, sal_Unicode*** pValueList, sal_uInt32* pLen) const +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + RegValueType valueType; + sal_uInt32 valueSize; + storeAccessMode accessMode = VALUE_MODE_OPEN; + + if (m_pRegistry->isReadOnly()) + { + accessMode = VALUE_MODE_OPENREAD; + } + + OUString sImplValueName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); + sImplValueName += valueName; + + REG_GUARD(m_pRegistry->m_mutex); + + if ( rValue.create(m_storeFile, m_name + m_pRegistry->ROOT, sImplValueName, accessMode) ) + { + pValueList = NULL; + *pLen = 0; + return REG_VALUE_NOT_EXISTS; + } + + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); + + sal_uInt32 readBytes; + if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) ) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (readBytes != VALUE_HEADERSIZE) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + sal_uInt8 type = *((sal_uInt8*)pBuffer); + valueType = (RegValueType)type; + + if (valueType != RG_VALUETYPE_UNICODELIST) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize); + + rtl_freeMemory(pBuffer); + + pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize); + + if ( rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, readBytes) ) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (readBytes != valueSize) + { + pValueList = NULL; + *pLen = 0; + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + sal_uInt32 len = 0; + readUINT32(pBuffer, len); + + *pLen = len; + sal_Unicode** pVList = (sal_Unicode**)rtl_allocateZeroMemory(len * sizeof(sal_Unicode*)); + + sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays; + sal_uInt32 sLen = 0; + + sal_Unicode *pValue; + for (int i=0; i < len; i++) + { + readUINT32(pBuffer+offset, sLen); + + offset += 4; + + pValue = (sal_Unicode*)rtl_allocateMemory((sLen / 2) * sizeof(sal_Unicode)); + readString(pBuffer+offset, pValue, sLen); + pVList[i] = pValue; + + offset += sLen; + } + + *pValueList = pVList; + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; +} + +//********************************************************************* +// getKeyType() +// +RegError ORegKey::getKeyType(const OUString& name, RegKeyType* pKeyType) const +{ + ORegKey* pKey; + RegError _ret = REG_NO_ERROR; + + *pKeyType = RG_KEYTYPE; + + REG_GUARD(m_pRegistry->m_mutex); + + if ( name.getLength() ) + { + if ((_ret = ((ORegKey*)this)->openKey(name, (RegKeyHandle*)&pKey, RESOLVE_PART))) + return _ret; + + if (pKey->isLink()) + *pKeyType = RG_LINKTYPE; + + ((ORegKey*)this)->closeKey((RegKeyHandle)pKey); + return _ret; + } else + { + if (m_isLink) + *pKeyType = RG_LINKTYPE; + + return _ret; + } +} + +//********************************************************************* +// createLink() +// +RegError ORegKey::createLink(const OUString& linkName, const OUString& linkTarget) +{ + ORegKey* pKey; + RegError _ret = REG_NO_ERROR; + + if ( !linkName.getLength() ) + return REG_INVALID_LINKNAME; + + if ( !linkTarget.getLength() ) + return REG_INVALID_LINKTARGET; + + REG_GUARD(m_pRegistry->m_mutex); + + if (m_pRegistry->openKey(this, linkName, (RegKeyHandle*)&pKey, RESOLVE_PART)) + { + if (_ret = m_pRegistry->createKey(this, linkName, (RegKeyHandle*)&pKey)) + return _ret; + } else + { + if (!pKey->isLink()) + { + m_pRegistry->closeKey(pKey); + return REG_INVALID_LINK; + } + } + + if (_ret = pKey->setValue(OUString( RTL_CONSTASCII_USTRINGPARAM("LINK_TARGET") ), + RG_VALUETYPE_UNICODE, (RegValue)linkTarget.getStr(), (linkTarget.getLength()+1)*2)) + { + m_pRegistry->closeKey(pKey); + _ret = m_pRegistry->deleteKey(this, linkName); + return _ret; + } + + return m_pRegistry->closeKey(pKey); +} + +//********************************************************************* +// deleteLink() +// +RegError ORegKey::deleteLink(const OUString& linkName) +{ + return (m_pRegistry->deleteLink(this, linkName)); +} + +//********************************************************************* +// getLinkTarget() +// +RegError ORegKey::getLinkTarget(const OUString& linkName, OUString& linkTarget) const +{ + ORegKey* pKey; + RegError _ret = REG_NO_ERROR; + + REG_GUARD(m_pRegistry->m_mutex); + + if ( linkName.getLength() ) + { + if (_ret = ((ORegKey*)this)->openKey(linkName, (RegKeyHandle*)&pKey, RESOLVE_PART)) + return REG_INVALID_LINK; + + _ret = pKey->getLinkTarget(OUString(), linkTarget); + ((ORegKey*)this)->closeKey((RegKeyHandle)pKey); + return _ret; + } else + { + if (m_isLink) + { + linkTarget = m_link; + return REG_NO_ERROR; + } else + return REG_LINKTARGET_NOT_EXIST; + } +} + +RegError ORegKey::getResolvedKeyName(const OUString& keyName, + OUString& resolvedName, + sal_Bool firstLinkOnly) +{ + return m_pRegistry->getResolvedKeyName((ORegKey*)this, keyName, resolvedName, firstLinkOnly); +} + +//********************************************************************* +// countSubKeys() +// +sal_uInt32 ORegKey::countSubKeys() +{ + REG_GUARD(m_pRegistry->m_mutex); + + OStoreDirectory::iterator iter; + OStoreDirectory rStoreDir = getStoreDir(); + storeError _err = rStoreDir.first(iter); + sal_uInt32 count = 0; + + while ( _err == store_E_None ) + { + if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR ) + { + count++; + } + + _err = rStoreDir.next(iter); + } + + return count; +} + + +//********************************************************************* +// checkLink() +// +sal_Bool ORegKey::checkLink() +{ + RegValueType valueType = RG_VALUETYPE_NOT_DEFINED; + sal_uInt32 valueSize = 0; + + OUString linkTarget( OUString( RTL_CONSTASCII_USTRINGPARAM("LINK_TARGET") )); + if (!((ORegKey*)this)->getValueInfo( linkTarget, &valueType, &valueSize)) + { + sal_Unicode* value = (sal_Unicode*)rtl_allocateMemory(valueSize); + if (!((ORegKey*)this)->getValue( linkTarget, value)) + { + m_link = OUString(value); + m_isLink = sal_True; + } + + rtl_freeMemory(value); + + return sal_True; + } + + return sal_False; +} + +OStoreDirectory ORegKey::getStoreDir() +{ + OStoreDirectory rStoreDir; + OUString fullPath; + OUString relativName; + storeAccessMode accessMode = KEY_MODE_OPEN; + + if ( m_name.equals(m_pRegistry->ROOT) ) + { + fullPath = OUString(); + relativName = OUString(); + } else + { + fullPath = m_name.copy(0, m_name.lastIndexOf('/') + 1); + relativName = m_name.copy(m_name.lastIndexOf('/') + 1); + } + + if (m_pRegistry->isReadOnly()) + { + accessMode = KEY_MODE_OPENREAD; + } + + rStoreDir.create(m_storeFile, fullPath, relativName, accessMode); + + return rStoreDir; +} + diff --git a/registry/source/keyimpl.hxx b/registry/source/keyimpl.hxx new file mode 100644 index 000000000000..17a638026980 --- /dev/null +++ b/registry/source/keyimpl.hxx @@ -0,0 +1,215 @@ +/************************************************************************* + * + * $RCSfile: keyimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _KEYIMPL_HXX_ +#define _KEYIMPL_HXX_ + +#ifndef _REGISTRY_REGISTRY_H_ +#include <registry/registry.h> +#endif + +#ifndef _REGIMPL_HXX_ +#include "regimpl.hxx" +#endif + +#ifndef _RTL_STRING_HXX_ +#include <rtl/string.hxx> +#endif + +using namespace rtl; +using namespace store; + +class ORegKey +{ +public: + + ORegKey(const OUString& keyName, const OStoreDirectory& rStoreDir, ORegistry* pReg); + ORegKey(const OUString& keyName, const OUString& linkName, + const OStoreDirectory& rStoreDir, ORegistry* pReg); + + sal_uInt32 acquire() + { return ++m_refCount; } + + sal_uInt32 release() + { return --m_refCount; } + + RegError createKey(const OUString& keyName, RegKeyHandle* phNewKey); + + RegError openKey(const OUString& keyName, RegKeyHandle* phOpenKey, + RESOLVE eResolve=RESOLVE_FULL); + + RegError openSubKeys(const OUString& keyName, + RegKeyHandle** phOpenSubKeys, + sal_uInt32* pnSubKeys); + + RegError getKeyNames(const OUString& keyName, + rtl_uString*** pSubKeyNames, + sal_uInt32* pnSubKeys); + + RegError closeSubKeys(RegKeyHandle* phSubKeys, sal_uInt32 len); + + RegError closeKey(RegKeyHandle hKey); + + RegError deleteKey(const OUString& keyName); + + RegError getValueInfo(const OUString& valueName, + RegValueType* pValueTye, + sal_uInt32* pValueSize) const; + + RegError setValue(const OUString& valueName, + RegValueType vType, + RegValue value, + sal_uInt32 vSize); + + RegError setLongListValue(const OUString& valueName, + sal_Int32* pValueList, + sal_uInt32 len); + + RegError setStringListValue(const OUString& valueName, + sal_Char** pValueList, + sal_uInt32 len); + + RegError setUnicodeListValue(const OUString& valueName, + sal_Unicode** pValueList, + sal_uInt32 len); + + RegError getValue(const OUString& valueName, RegValue value) const; + + RegError getLongListValue(const OUString& valueName, + sal_Int32** pValueList, + sal_uInt32* pLen) const; + + RegError getStringListValue(const OUString& valueName, + sal_Char*** pValueList, + sal_uInt32* pLen) const; + + RegError getUnicodeListValue(const OUString& valueName, + sal_Unicode*** pValueList, + sal_uInt32* pLen) const; + + RegError createLink(const OUString& linkName, const OUString& linkTarget); + + RegError deleteLink(const OUString& linkName); + + RegError getKeyType(const OUString& name, + RegKeyType* pKeyType) const; + + RegError getLinkTarget(const OUString& linkName, + OUString& pLinkTarget) const; + + RegError getResolvedKeyName(const OUString& keyName, + OUString& resolvedName, + sal_Bool firstLinkOnly=sal_False); + +public: + ORegKey(); + virtual ~ORegKey(); + + + sal_Bool isDeleted() const + { return m_bDeleted; } + + void setDeleted(sal_Bool bKeyDeleted) + { m_bDeleted = bKeyDeleted; } + + sal_Bool isReadOnly() const + { return m_pRegistry->isReadOnly(); } + + sal_uInt32 countSubKeys(); + + sal_Bool isLink() const + { return m_isLink; } + + const OUString& getLinkTarget() const + { return m_link; } + + ORegistry* getRegistry() const + { return m_pRegistry; } + + const OStoreFile& getStoreFile() const + { return m_storeFile; } + + OStoreDirectory getStoreDir(); + + const OUString& getName() const + { return m_name; } + + sal_uInt32 getRefCount() const + { return m_refCount; } + + friend class ORegistry; +protected: + sal_Bool checkLink(); + + sal_uInt32 m_refCount; + OUString m_name; + OUString m_link; + sal_Bool m_bDeleted; + sal_Bool m_isLink; + ORegistry* m_pRegistry; + OStoreFile m_storeFile; +}; + + + +#endif + + diff --git a/registry/source/makefile.mk b/registry/source/makefile.mk new file mode 100644 index 000000000000..93a3ba530111 --- /dev/null +++ b/registry/source/makefile.mk @@ -0,0 +1,97 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=.. + +PRJNAME=registry +TARGET=regcpp + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : ..$/version.mk + +# ------------------------------------------------------------------ + +SLOFILES= \ + $(SLO)$/regimpl.obj \ + $(SLO)$/regkey.obj \ + $(SLO)$/registry.obj \ + $(SLO)$/keyimpl.obj \ + $(SLO)$/reflread.obj \ + $(SLO)$/reflwrit.obj + + +# NETBSD: somewhere we have to instantiate the static data members. +# NETBSD-1.2.1 doesn't know about weak symbols so the default mechanism for GCC won't work. +# SCO and MACOSX: the linker does know about weak symbols, but we can't ignore multiple defined symbols +.IF "$(OS)"=="NETBSD" || "$(OS)"=="SCO" || "$(OS)$(COM)"=="OS2GCC" || "$(OS)"=="MACOSX" +SLOFILES+=$(SLO)$/staticmb.obj +OBJFILES+=$(OBJ)$/staticmb.obj +.ENDIF + +# ------------------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/registry/source/reflcnst.hxx b/registry/source/reflcnst.hxx new file mode 100644 index 000000000000..a57addcce1cc --- /dev/null +++ b/registry/source/reflcnst.hxx @@ -0,0 +1,268 @@ +/************************************************************************* + * + * $RCSfile: reflcnst.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef __REFLCNST_HXX__ +#define __REFLCNST_HXX__ + +#ifndef __REGISTRY_REFLTYPE_HXX__ +#include <registry/refltype.hxx> +#endif + +#include <string.h> +#include <vos/macros.hxx> + +#define REGTYPE_IEEE_NATIVE 1 + +extern const sal_uInt32 magic; +extern const sal_uInt16 minorVersion; +extern const sal_uInt16 majorVersion; + +#define OFFSET_MAGIC 0 +#define OFFSET_SIZE (OFFSET_MAGIC + sizeof(magic)) +#define OFFSET_MINOR_VERSION (OFFSET_SIZE + sizeof(sal_uInt32)) +#define OFFSET_MAJOR_VERSION (OFFSET_MINOR_VERSION + sizeof(minorVersion)) +#define OFFSET_TYPE_CLASS (OFFSET_MAJOR_VERSION + sizeof(majorVersion)) +#define OFFSET_THIS_TYPE (OFFSET_TYPE_CLASS + sizeof(sal_uInt16)) +#define OFFSET_SUPER_TYPE (OFFSET_THIS_TYPE + sizeof(sal_uInt16)) +#define OFFSET_UIK (OFFSET_SUPER_TYPE + sizeof(sal_uInt16)) +#define OFFSET_DOKU (OFFSET_UIK + sizeof(sal_uInt16)) +#define OFFSET_FILENAME (OFFSET_DOKU + sizeof(sal_uInt16)) +#define OFFSET_CP_SIZE (OFFSET_FILENAME + sizeof(sal_uInt16)) +#define OFFSET_CP (OFFSET_CP_SIZE + sizeof(sal_uInt16)) + +#define CP_OFFSET_ENTRY_SIZE 0 +#define CP_OFFSET_ENTRY_TAG (CP_OFFSET_ENTRY_SIZE + sizeof(sal_uInt16)) +#define CP_OFFSET_ENTRY_DATA (CP_OFFSET_ENTRY_TAG + sizeof(sal_uInt16)) +#define CP_OFFSET_ENTRY_UIK1 CP_OFFSET_ENTRY_DATA +#define CP_OFFSET_ENTRY_UIK2 (CP_OFFSET_ENTRY_UIK1 + sizeof(sal_uInt32)) +#define CP_OFFSET_ENTRY_UIK3 (CP_OFFSET_ENTRY_UIK2 + sizeof(sal_uInt16)) +#define CP_OFFSET_ENTRY_UIK4 (CP_OFFSET_ENTRY_UIK3 + sizeof(sal_uInt16)) +#define CP_OFFSET_ENTRY_UIK5 (CP_OFFSET_ENTRY_UIK4 + sizeof(sal_uInt32)) + +#define FIELD_OFFSET_ACCESS 0 +#define FIELD_OFFSET_NAME (FIELD_OFFSET_ACCESS + sizeof(sal_uInt16)) +#define FIELD_OFFSET_TYPE (FIELD_OFFSET_NAME + sizeof(sal_uInt16)) +#define FIELD_OFFSET_VALUE (FIELD_OFFSET_TYPE + sizeof(sal_uInt16)) +#define FIELD_OFFSET_DOKU (FIELD_OFFSET_VALUE + sizeof(sal_uInt16)) +#define FIELD_OFFSET_FILENAME (FIELD_OFFSET_DOKU + sizeof(sal_uInt16)) +#define FIELD_ENTRY_SIZE (FIELD_OFFSET_FILENAME + sizeof(sal_uInt16)) + +#define PARAM_OFFSET_TYPE 0 +#define PARAM_OFFSET_MODE (PARAM_OFFSET_TYPE + sizeof(sal_uInt16)) +#define PARAM_OFFSET_NAME (PARAM_OFFSET_MODE + sizeof(sal_uInt16)) +#define PARAM_ENTRY_SIZE (PARAM_OFFSET_NAME + sizeof(sal_uInt16)) + +#define METHOD_OFFSET_SIZE 0 +#define METHOD_OFFSET_MODE (METHOD_OFFSET_SIZE + sizeof(sal_uInt16)) +#define METHOD_OFFSET_NAME (METHOD_OFFSET_MODE + sizeof(sal_uInt16)) +#define METHOD_OFFSET_RETURN (METHOD_OFFSET_NAME + sizeof(sal_uInt16)) +#define METHOD_OFFSET_DOKU (METHOD_OFFSET_RETURN + sizeof(sal_uInt16)) +#define METHOD_OFFSET_PARAM_COUNT (METHOD_OFFSET_DOKU + sizeof(sal_uInt16)) +#define METHOD_OFFSET_PARAM(i) (METHOD_OFFSET_PARAM_COUNT + sizeof(sal_uInt16) + (i * PARAM_ENTRY_SIZE)) + +#define REFERENCE_OFFSET_TYPE 0 +#define REFERENCE_OFFSET_NAME (REFERENCE_OFFSET_TYPE + sizeof(sal_uInt16)) +#define REFERENCE_OFFSET_DOKU (REFERENCE_OFFSET_NAME + sizeof(sal_uInt16)) +#define REFERENCE_OFFSET_ACCESS (REFERENCE_OFFSET_DOKU + sizeof(sal_uInt16)) +#define REFERENCE_ENTRY_SIZE (REFERENCE_OFFSET_ACCESS + sizeof(sal_uInt16)) + +enum CPInfoTag +{ + CP_TAG_INVALID = RT_TYPE_NONE, + CP_TAG_CONST_BOOL = RT_TYPE_BOOL, + CP_TAG_CONST_BYTE = RT_TYPE_BYTE, + CP_TAG_CONST_INT16 = RT_TYPE_INT16, + CP_TAG_CONST_UINT16 = RT_TYPE_UINT16, + CP_TAG_CONST_INT32 = RT_TYPE_INT32, + CP_TAG_CONST_UINT32 = RT_TYPE_UINT32, + CP_TAG_CONST_INT64 = RT_TYPE_INT64, + CP_TAG_CONST_UINT64 = RT_TYPE_UINT64, + CP_TAG_CONST_FLOAT = RT_TYPE_FLOAT, + CP_TAG_CONST_DOUBLE = RT_TYPE_DOUBLE, + CP_TAG_CONST_STRING = RT_TYPE_STRING, + CP_TAG_UTF8_NAME, + CP_TAG_UIK +}; + +inline sal_uInt32 writeBYTE(sal_uInt8* buffer, sal_uInt8 v) +{ + buffer[0] = v; + + return sizeof(sal_uInt8); +} + +inline sal_uInt16 readBYTE(const sal_uInt8* buffer, sal_uInt8& v) +{ + v = buffer[0]; + + return sizeof(sal_uInt8); +} + +inline sal_uInt32 writeINT16(sal_uInt8* buffer, sal_Int16 v) +{ + buffer[0] = (sal_uInt8)((v >> 8) & 0xFF); + buffer[1] = (sal_uInt8)((v >> 0) & 0xFF); + + return sizeof(sal_Int16); +} + +inline sal_uInt32 readINT16(const sal_uInt8* buffer, sal_Int16& v) +{ + v = ((buffer[0] << 8) | (buffer[1] << 0)); + + return sizeof(sal_Int16); +} + +inline sal_uInt32 writeUINT16(sal_uInt8* buffer, sal_uInt16 v) +{ + buffer[0] = (sal_uInt8)((v >> 8) & 0xFF); + buffer[1] = (sal_uInt8)((v >> 0) & 0xFF); + + return sizeof(sal_uInt16); +} + +inline sal_uInt32 readUINT16(const sal_uInt8* buffer, sal_uInt16& v) +{ + v = ((buffer[0] << 8) | (buffer[1] << 0)); + + return sizeof(sal_uInt16); +} + +inline sal_uInt32 writeINT32(sal_uInt8* buffer, sal_Int32 v) +{ + buffer[0] = (sal_uInt8)((v >> 24) & 0xFF); + buffer[1] = (sal_uInt8)((v >> 16) & 0xFF); + buffer[2] = (sal_uInt8)((v >> 8) & 0xFF); + buffer[3] = (sal_uInt8)((v >> 0) & 0xFF); + + return sizeof(sal_Int32); +} + +inline sal_uInt32 readINT32(const sal_uInt8* buffer, sal_Int32& v) +{ + v = ( + (buffer[0] << 24) | + (buffer[1] << 16) | + (buffer[2] << 8) | + (buffer[3] << 0) + ); + + return sizeof(sal_Int32); +} + +inline sal_uInt32 writeUINT32(sal_uInt8* buffer, sal_uInt32 v) +{ + buffer[0] = (sal_uInt8)((v >> 24) & 0xFF); + buffer[1] = (sal_uInt8)((v >> 16) & 0xFF); + buffer[2] = (sal_uInt8)((v >> 8) & 0xFF); + buffer[3] = (sal_uInt8)((v >> 0) & 0xFF); + + return sizeof(sal_uInt32); +} + +inline sal_uInt32 readUINT32(const sal_uInt8* buffer, sal_uInt32& v) +{ + v = ( + (buffer[0] << 24) | + (buffer[1] << 16) | + (buffer[2] << 8) | + (buffer[3] << 0) + ); + + return sizeof(sal_uInt32); +} + +inline sal_uInt32 writeUtf8(sal_uInt8* buffer, const sal_Char* v) +{ + sal_uInt32 size = strlen(v) + 1; + + memcpy(buffer, v, size); + + return (size); +} + +inline sal_uInt32 readUtf8(const sal_uInt8* buffer, sal_Char* v, sal_uInt32 maxSize) +{ + sal_uInt32 size = VOS_MIN(strlen((const sal_Char*) buffer) + 1, maxSize); + + memcpy(v, buffer, size); + + if (size == maxSize) v[size - 1] = '\0'; + + return (size); +} + + +sal_uInt32 writeFloat(sal_uInt8* buffer, float v); +sal_uInt32 readFloat(const sal_uInt8* buffer, float& v); +sal_uInt32 writeDouble(sal_uInt8* buffer, double v); +sal_uInt32 readDouble(const sal_uInt8* buffer, double& v); +sal_uInt32 writeString(sal_uInt8* buffer, const sal_Unicode* v); +sal_uInt32 readString(const sal_uInt8* buffer, sal_Unicode* v, sal_uInt32 maxSize); + +sal_uInt32 UINT16StringLen(const sal_uInt8* wstring); + +#endif + + + + + diff --git a/registry/source/reflread.cxx b/registry/source/reflread.cxx new file mode 100644 index 000000000000..cb462132db24 --- /dev/null +++ b/registry/source/reflread.cxx @@ -0,0 +1,1602 @@ +/************************************************************************* + * + * $RCSfile: reflread.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef MAC +#include <memory.h> +#endif +#include <osl/types.h> + +#include <registry/reflread.hxx> +#include "reflcnst.hxx" + +using namespace vos; + +static CPInfoTag aTag; + +static sal_Char NULL_STRING[1] = { 0 }; +static sal_Unicode NULL_WSTRING[1] = { 0 }; + +const sal_uInt32 magic = 0x12345678; +const sal_uInt16 minorVersion = 0x0000; +const sal_uInt16 majorVersion = 0x0001; + +#if defined ( GCC ) && ( defined ( SCO ) || defined ( NETBSD ) ) +ORealDynamicLoader* ODynamicLoader<RegistryTypeReader_Api>::m_pLoader = NULL; +#endif + +/************************************************************************** + + class BlopObject + + holds any data in a flat memory buffer + +**************************************************************************/ + +class BlopObject +{ +public: + const sal_uInt8* m_pBuffer; + sal_uInt32 m_bufferLen; + sal_Bool m_isCopied; + + BlopObject(const sal_uInt8* buffer, sal_uInt32 len, sal_Bool copyBuffer); + ~BlopObject(); + + inline sal_uInt8 readBYTE(sal_uInt32 index) const + { + return m_pBuffer[index]; + } + + inline sal_Int16 readINT16(sal_uInt32 index) const + { + return ((m_pBuffer[index] << 8) | (m_pBuffer[index+1] << 0)); + } + + inline sal_uInt16 readUINT16(sal_uInt32 index) const + { + return ((m_pBuffer[index] << 8) | (m_pBuffer[index+1] << 0)); + } + + inline sal_Int32 readINT32(sal_uInt32 index) const + { + return ( + (m_pBuffer[index] << 24) | + (m_pBuffer[index+1] << 16) | + (m_pBuffer[index+2] << 8) | + (m_pBuffer[index+3] << 0) + ); + } + + inline sal_uInt32 readUINT32(sal_uInt32 index) const + { + return ( + (m_pBuffer[index] << 24) | + (m_pBuffer[index+1] << 16) | + (m_pBuffer[index+2] << 8) | + (m_pBuffer[index+3] << 0) + ); + } +}; + +BlopObject::BlopObject(const sal_uInt8* buffer, sal_uInt32 len, sal_Bool copyBuffer) + : m_isCopied(copyBuffer) + , m_bufferLen(len) +{ + if (m_isCopied) + { + sal_uInt8* newBuffer = new sal_uInt8[len]; + memcpy(newBuffer, buffer, len); + m_pBuffer = newBuffer; + } + else + { + m_pBuffer = buffer; + } +} + +BlopObject::~BlopObject() +{ + if (m_isCopied && m_pBuffer) + { +#ifdef OS2 + delete (sal_uInt8 *)m_pBuffer; +#else + delete[] const_cast<sal_uInt8*>(m_pBuffer); +#endif + } +} + +/************************************************************************** + + class StringCache + +**************************************************************************/ + +class StringCache +{ +public: + sal_Unicode** m_stringTable; + sal_uInt16 m_numOfStrings; + sal_uInt16 m_stringsCopied; + + StringCache(sal_uInt16 size); + ~StringCache(); + + const sal_Unicode* getString(sal_uInt16 index); + sal_uInt16 createString(const sal_uInt8* buffer); +}; + +StringCache::StringCache(sal_uInt16 size) + : m_numOfStrings(size) + , m_stringsCopied(0) + , m_stringTable(NULL) +{ + m_stringTable = new sal_Unicode*[m_numOfStrings]; + + for (sal_uInt16 i = 0; i < m_numOfStrings; i++) + { + m_stringTable[i] = NULL; + } +} + +StringCache::~StringCache() +{ + if (m_stringTable) + { + for (sal_uInt16 i = 0; i < m_stringsCopied; i++) + { + delete[] m_stringTable[i]; + } + + delete[] m_stringTable; + } +} + +const sal_Unicode* StringCache::getString(sal_uInt16 index) +{ + if ((index > 0) && (index <= m_stringsCopied)) + return m_stringTable[index - 1]; + else + return NULL; +} + +sal_uInt16 StringCache::createString(const sal_uInt8* buffer) +{ + if (m_stringsCopied < m_numOfStrings) + { + sal_uInt32 len = UINT16StringLen(buffer); + + m_stringTable[m_stringsCopied] = new sal_Unicode[len + 1]; + + readString(buffer, m_stringTable[m_stringsCopied], (len + 1) * sizeof(sal_Unicode)); + + return ++m_stringsCopied; + } + else + return 0; +} + +/************************************************************************** + + class ConstantPool + +**************************************************************************/ + +class ConstantPool : public BlopObject +{ +public: + + sal_uInt16 m_numOfEntries; + sal_Int32* m_pIndex; // index values may be < 0 for cached string constants + + StringCache* m_pStringCache; + + ConstantPool(const sal_uInt8* buffer, sal_uInt16 numEntries) + : BlopObject(buffer, 0, sal_False) + , m_numOfEntries(numEntries) + , m_pIndex(NULL) + , m_pStringCache(NULL) + { + } + + ~ConstantPool(); + + sal_uInt32 parseIndex(); + + CPInfoTag readTag(sal_uInt16 index); + + const sal_Char* readUTF8NameConstant(sal_uInt16 index); + sal_Bool readBOOLConstant(sal_uInt16 index); + sal_uInt8 readBYTEConstant(sal_uInt16 index); + sal_Int16 readINT16Constant(sal_uInt16 index); + sal_uInt16 readUINT16Constant(sal_uInt16 index); + sal_Int32 readINT32Constant(sal_uInt16 index); + sal_uInt32 readUINT32Constant(sal_uInt16 index); + float readFloatConstant(sal_uInt16 index); + double readDoubleConstant(sal_uInt16 index); + const sal_Unicode* readStringConstant(sal_uInt16 index); + void readUIK(sal_uInt16 index, RTUik* uik); +}; + +ConstantPool::~ConstantPool() +{ + if (m_pIndex) delete[] m_pIndex; + + if (m_pStringCache) + { + delete m_pStringCache; + } +} + +sal_uInt32 ConstantPool::parseIndex() +{ + if (m_pIndex) + { + delete[] m_pIndex; + m_pIndex = NULL; + } + + if (m_pStringCache) + { + delete m_pStringCache; + m_pStringCache = NULL; + } + + sal_uInt32 offset = 0; + sal_uInt16 numOfStrings = 0; + + if (m_numOfEntries) + { + m_pIndex = new sal_Int32[m_numOfEntries]; + + for (int i = 0; i < m_numOfEntries; i++) + { + m_pIndex[i] = (sal_Int32) offset; + + offset += readUINT16(offset); + + if ( + ((CPInfoTag) readUINT16(m_pIndex[i] + CP_OFFSET_ENTRY_TAG)) == + CP_TAG_CONST_STRING + ) + { + numOfStrings++; + } + + } + } + + if (numOfStrings) + { + m_pStringCache = new StringCache(numOfStrings); + } + + m_bufferLen = offset; + + return offset; +} + +CPInfoTag ConstantPool::readTag(sal_uInt16 index) +{ + CPInfoTag tag = CP_TAG_INVALID; + + if (m_pIndex && (index > 0) && (index <= m_numOfEntries)) + { + tag = (CPInfoTag) readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG); + } + + return tag; +} + +const sal_Char* ConstantPool::readUTF8NameConstant(sal_uInt16 index) +{ + const sal_Char* aName = NULL_STRING; + + if (m_pIndex && (index > 0) && (index <= m_numOfEntries)) + { + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_UTF8_NAME) + { + aName = (const sal_Char*) (m_pBuffer + m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); + } + } + + return aName; +} + +sal_Bool ConstantPool::readBOOLConstant(sal_uInt16 index) +{ + sal_Bool aBool = sal_False; + + if (m_pIndex && (index> 0) && (index <= m_numOfEntries)) + { + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_BOOL) + { + aBool = (sal_Bool) readBYTE(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); + } + } + + return aBool; +} + +sal_uInt8 ConstantPool::readBYTEConstant(sal_uInt16 index) +{ + sal_uInt8 aByte = sal_False; + + if (m_pIndex && (index> 0) && (index <= m_numOfEntries)) + { + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_BYTE) + { + aByte = readBYTE(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); + } + } + + return aByte; +} + +sal_Int16 ConstantPool::readINT16Constant(sal_uInt16 index) +{ + sal_Int16 aINT16 = sal_False; + + if (m_pIndex && (index> 0) && (index <= m_numOfEntries)) + { + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_INT16) + { + aINT16 = readINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); + } + } + + return aINT16; +} + +sal_uInt16 ConstantPool::readUINT16Constant(sal_uInt16 index) +{ + sal_uInt16 asal_uInt16 = sal_False; + + if (m_pIndex && (index> 0) && (index <= m_numOfEntries)) + { + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_UINT16) + { + asal_uInt16 = readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); + } + } + + return asal_uInt16; +} + +sal_Int32 ConstantPool::readINT32Constant(sal_uInt16 index) +{ + sal_Int32 aINT32 = sal_False; + + if (m_pIndex && (index> 0) && (index <= m_numOfEntries)) + { + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_INT32) + { + aINT32 = readINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); + } + } + + return aINT32; +} + +sal_uInt32 ConstantPool::readUINT32Constant(sal_uInt16 index) +{ + sal_uInt32 aUINT32 = sal_False; + + if (m_pIndex && (index> 0) && (index <= m_numOfEntries)) + { + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_UINT32) + { + aUINT32 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); + } + } + + return aUINT32; +} + +float ConstantPool::readFloatConstant(sal_uInt16 index) +{ + union + { + float v; + sal_uInt32 b; + } x; + + if (m_pIndex && (index> 0) && (index <= m_numOfEntries)) + { + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_FLOAT) + { +#ifdef REGTYPE_IEEE_NATIVE + x.b = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); +#else +# error no IEEE +#endif + } + } + + return x.v; +} + +double ConstantPool::readDoubleConstant(sal_uInt16 index) +{ + union + { + double v; + struct + { + sal_uInt32 b1; + sal_uInt32 b2; + } b; + } x; + + if (m_pIndex && (index> 0) && (index <= m_numOfEntries)) + { + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_DOUBLE) + { + +#ifdef REGTYPE_IEEE_NATIVE +# ifdef OSL_BIGENDIAN + x.b.b1 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); + x.b.b2 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA + sizeof(sal_uInt32)); +# else + x.b.b1 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA + sizeof(sal_uInt32)); + x.b.b2 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); +# endif +#else +# error no IEEE +#endif + } + } + + return x.v; +} + +const sal_Unicode* ConstantPool::readStringConstant(sal_uInt16 index) +{ + const sal_Unicode* aString = NULL_WSTRING; + + if (m_pIndex && (index> 0) && (index <= m_numOfEntries) && m_pStringCache) + { + if (m_pIndex[index - 1] >= 0) + { + // create cached string now + + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_STRING) + { + m_pIndex[index - 1] = -1 * m_pStringCache->createString(m_pBuffer + m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA); + } + } + + aString = m_pStringCache->getString((sal_uInt16) (m_pIndex[index - 1] * -1)); + } + + return aString; +} + +void ConstantPool::readUIK(sal_uInt16 index, RTUik* uik) +{ + if (index == 0) + { + uik->m_Data1 = 0; + uik->m_Data2 = 0; + uik->m_Data3 = 0; + uik->m_Data4 = 0; + uik->m_Data5 = 0; + } + else if (m_pIndex && (index <= m_numOfEntries)) + { + if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_UIK) + { + uik->m_Data1 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_UIK1); + uik->m_Data2 = readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_UIK2); + uik->m_Data3 = readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_UIK3); + uik->m_Data4 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_UIK4); + uik->m_Data5 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_UIK5); + } + } +} + +/************************************************************************** + + class FieldList + +**************************************************************************/ + +class FieldList : public BlopObject +{ +public: + + sal_uInt16 m_numOfEntries; + ConstantPool* m_pCP; + + FieldList(const sal_uInt8* buffer, sal_uInt16 numEntries, ConstantPool* pCP) + : BlopObject(buffer, 0, sal_False) + , m_numOfEntries(numEntries) + , m_pCP(pCP) + { + } + + sal_uInt32 parseIndex(); + + const sal_Char* getFieldName(sal_uInt16 index); + const sal_Char* getFieldType(sal_uInt16 index); + RTFieldAccess getFieldAccess(sal_uInt16 index); + RTValueType getFieldConstValue(sal_uInt16 index, RTConstValueUnion* value); + const sal_Char* getFieldDoku(sal_uInt16 index); + const sal_Char* getFieldFileName(sal_uInt16 index); +}; + +sal_uInt32 FieldList::parseIndex() +{ + return (m_numOfEntries * (sizeof(sal_uInt16) * 6)); +} + +const sal_Char* FieldList::getFieldName(sal_uInt16 index) +{ + const sal_Char* aName = NULL; + + if (index <= m_numOfEntries) + { + aName = m_pCP->readUTF8NameConstant(readUINT16((index * FIELD_ENTRY_SIZE) + FIELD_OFFSET_NAME)); + } + + return aName; +} + +const sal_Char* FieldList::getFieldType(sal_uInt16 index) +{ + const sal_Char* aName = NULL; + + if (index <= m_numOfEntries) + { + aName = m_pCP->readUTF8NameConstant(readUINT16((index * FIELD_ENTRY_SIZE) + FIELD_OFFSET_TYPE)); + } + + return aName; +} + +RTFieldAccess FieldList::getFieldAccess(sal_uInt16 index) +{ + RTFieldAccess aAccess; + + if (index <= m_numOfEntries) + { + aAccess = (RTFieldAccess) readUINT16((index * FIELD_ENTRY_SIZE) + FIELD_OFFSET_ACCESS); + } + + return aAccess; +} + +RTValueType FieldList::getFieldConstValue(sal_uInt16 index, RTConstValueUnion* value) +{ + RTValueType ret = RT_TYPE_NONE; + + if (index <= m_numOfEntries) + { + sal_uInt16 cpIndex = readUINT16((index * FIELD_ENTRY_SIZE) + FIELD_OFFSET_VALUE); + + switch (m_pCP->readTag(cpIndex)) + { + case CP_TAG_CONST_BOOL: + value->aBool = m_pCP->readBOOLConstant(cpIndex); + ret = RT_TYPE_BOOL; + break; + case CP_TAG_CONST_BYTE: + value->aByte = m_pCP->readBYTEConstant(cpIndex); + ret = RT_TYPE_BYTE; + break; + case CP_TAG_CONST_INT16: + value->aShort = m_pCP->readINT16Constant(cpIndex); + ret = RT_TYPE_INT16; + break; + case CP_TAG_CONST_UINT16: + value->aUShort = m_pCP->readUINT16Constant(cpIndex); + ret = RT_TYPE_UINT16; + break; + case CP_TAG_CONST_INT32: + value->aLong = m_pCP->readINT32Constant(cpIndex); + ret = RT_TYPE_INT32; + break; + case CP_TAG_CONST_UINT32: + value->aULong = m_pCP->readUINT32Constant(cpIndex); + ret = RT_TYPE_UINT32; + break; + case CP_TAG_CONST_INT64: +// value->aHyper = m_pCP->readINT64Constant(cpIndex); + ret = RT_TYPE_INT64; + break; + case CP_TAG_CONST_UINT64: +// value->aUHyper = m_pCP->readUINT64Constant(cpIndex); + ret = RT_TYPE_UINT64; + break; + case CP_TAG_CONST_FLOAT: + value->aFloat = m_pCP->readFloatConstant(cpIndex); + ret = RT_TYPE_FLOAT; + break; + case CP_TAG_CONST_DOUBLE: + value->aDouble = m_pCP->readDoubleConstant(cpIndex); + ret = RT_TYPE_DOUBLE; + break; + case CP_TAG_CONST_STRING: + value->aString = m_pCP->readStringConstant(cpIndex); + ret = RT_TYPE_STRING; + break; + default: + break; + } + } + + return ret; +} + +const sal_Char* FieldList::getFieldDoku(sal_uInt16 index) +{ + const sal_Char* aDoku = NULL; + + if (index <= m_numOfEntries) + { + aDoku = m_pCP->readUTF8NameConstant(readUINT16((index * FIELD_ENTRY_SIZE) + FIELD_OFFSET_DOKU)); + } + + return aDoku; +} + +const sal_Char* FieldList::getFieldFileName(sal_uInt16 index) +{ + const sal_Char* aFileName = NULL; + + if (index <= m_numOfEntries) + { + aFileName = m_pCP->readUTF8NameConstant(readUINT16((index * FIELD_ENTRY_SIZE) + FIELD_OFFSET_FILENAME)); + } + + return aFileName; +} + +/************************************************************************** + + class ReferenceList + +**************************************************************************/ + +class ReferenceList : public BlopObject +{ +public: + + sal_uInt16 m_numOfEntries; + ConstantPool* m_pCP; + + ReferenceList(const sal_uInt8* buffer, sal_uInt16 numEntries, ConstantPool* pCP) + : BlopObject(buffer, 0, sal_False) + , m_numOfEntries(numEntries) + , m_pCP(pCP) + { + } + + sal_uInt32 parseIndex(); + + const sal_Char* getReferenceName(sal_uInt16 index); + RTReferenceType getReferenceType(sal_uInt16 index); + const sal_Char* getReferenceDoku(sal_uInt16 index); + RTFieldAccess getReferenceAccess(sal_uInt16 index); +}; + +sal_uInt32 ReferenceList::parseIndex() +{ + return (m_numOfEntries * (sizeof(sal_uInt16) * 4)); +} + +const sal_Char* ReferenceList::getReferenceName(sal_uInt16 index) +{ + const sal_Char* aName = NULL; + + if (index <= m_numOfEntries) + { + aName = m_pCP->readUTF8NameConstant(readUINT16((index * REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_NAME)); + } + + return aName; +} + +RTReferenceType ReferenceList::getReferenceType(sal_uInt16 index) +{ + RTReferenceType refType; + + if (index <= m_numOfEntries) + { + refType = (RTReferenceType) readUINT16((index * REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_TYPE); + } + + return refType; +} + +const sal_Char* ReferenceList::getReferenceDoku(sal_uInt16 index) +{ + const sal_Char* aDoku = NULL; + + if (index <= m_numOfEntries) + { + aDoku = m_pCP->readUTF8NameConstant(readUINT16((index * REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_DOKU)); + } + + return aDoku; +} + +RTFieldAccess ReferenceList::getReferenceAccess(sal_uInt16 index) +{ + RTFieldAccess aAccess; + + if (index <= m_numOfEntries) + { + aAccess = (RTFieldAccess) readUINT16((index * REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_ACCESS); + } + + return aAccess; +} + +/************************************************************************** + + class MethodList + +**************************************************************************/ + +class MethodList : public BlopObject +{ +public: + + sal_uInt16 m_numOfEntries; + sal_uInt32* m_pIndex; + ConstantPool* m_pCP; + + MethodList(const sal_uInt8* buffer, sal_uInt16 numEntries, ConstantPool* pCP) + : BlopObject(buffer, 0, sal_False) + , m_numOfEntries(numEntries) + , m_pIndex(NULL) + , m_pCP(pCP) + { + } + + ~MethodList(); + + sal_uInt32 parseIndex(); + + const sal_Char* getMethodName(sal_uInt16 index); + sal_uInt16 getMethodParamCount(sal_uInt16 index); + const sal_Char* getMethodParamType(sal_uInt16 index, sal_uInt16 paramIndex); + const sal_Char* getMethodParamName(sal_uInt16 index, sal_uInt16 paramIndex); + RTParamMode getMethodParamMode(sal_uInt16 index, sal_uInt16 paramIndex); + sal_uInt16 getMethodExcCount(sal_uInt16 index); + const sal_Char* getMethodExcType(sal_uInt16 index, sal_uInt16 excIndex); + const sal_Char* getMethodReturnType(sal_uInt16 index); + RTMethodMode getMethodMode(sal_uInt16 index); + const sal_Char* getMethodDoku(sal_uInt16 index); +}; + +MethodList::~MethodList() +{ + if (m_pIndex) delete[] m_pIndex; +} + +sal_uInt32 MethodList::parseIndex() +{ + if (m_pIndex) + { + delete[] m_pIndex; + m_pIndex = NULL; + } + + sal_uInt32 offset = 0; + + if (m_numOfEntries) + { + m_pIndex = new sal_uInt32[m_numOfEntries]; + + for (int i = 0; i < m_numOfEntries; i++) + { + m_pIndex[i] = offset; + + offset += readUINT16(offset); + } + } + + return offset; +} + +const sal_Char* MethodList::getMethodName(sal_uInt16 index) +{ + const sal_Char* aName = NULL; + + if (index <= m_numOfEntries) + { + aName = m_pCP->readUTF8NameConstant(readUINT16(m_pIndex[index] + METHOD_OFFSET_NAME)); + } + + return aName; +} + +sal_uInt16 MethodList::getMethodParamCount(sal_uInt16 index) +{ + sal_uInt16 aCount = 0; + + if (index <= m_numOfEntries) + { + aCount = readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT); + } + + return aCount; +} + +const sal_Char* MethodList::getMethodParamType(sal_uInt16 index, sal_uInt16 paramIndex) +{ + const sal_Char* aName = NULL; + + if ((index <= m_numOfEntries) && (paramIndex <= readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT))) + { + aName = m_pCP->readUTF8NameConstant( + readUINT16( + m_pIndex[index] + + METHOD_OFFSET_PARAM(paramIndex) + + PARAM_OFFSET_TYPE)); + } + + return aName; +} + +const sal_Char* MethodList::getMethodParamName(sal_uInt16 index, sal_uInt16 paramIndex) +{ + const sal_Char* aName = NULL; + + if ((index <= m_numOfEntries) && (paramIndex <= readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT))) + { + aName = m_pCP->readUTF8NameConstant( + readUINT16( + m_pIndex[index] + + METHOD_OFFSET_PARAM(paramIndex) + + PARAM_OFFSET_NAME)); + } + + return aName; +} + +RTParamMode MethodList::getMethodParamMode(sal_uInt16 index, sal_uInt16 paramIndex) +{ + RTParamMode aMode = RT_PARAM_INVALID; + + if ((index <= m_numOfEntries) && (paramIndex <= readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT))) + { + aMode = (RTParamMode) readUINT16( + m_pIndex[index] + + METHOD_OFFSET_PARAM(paramIndex) + + PARAM_OFFSET_MODE); + } + + return aMode; +} + +sal_uInt16 MethodList::getMethodExcCount(sal_uInt16 index) +{ + sal_uInt16 aCount = 0; + + if (index <= m_numOfEntries) + { + aCount = readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM(readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT))); + } + + return aCount; +} + +const sal_Char* MethodList::getMethodExcType(sal_uInt16 index, sal_uInt16 excIndex) +{ + const sal_Char* aName = NULL; + + if (index <= m_numOfEntries) + { + sal_uInt32 excOffset = m_pIndex[index] + METHOD_OFFSET_PARAM(readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT)); + + if (excIndex <= readUINT16(excOffset)) + { + aName = m_pCP->readUTF8NameConstant( + readUINT16( + excOffset + + sizeof(sal_uInt16) + + (excIndex * sizeof(sal_uInt16)))); + } + } + + return aName; +} + +const sal_Char* MethodList::getMethodReturnType(sal_uInt16 index) +{ + const sal_Char* aName = NULL; + + if (index <= m_numOfEntries) + { + aName = m_pCP->readUTF8NameConstant(readUINT16(m_pIndex[index] + METHOD_OFFSET_RETURN)); + } + + return aName; +} + +RTMethodMode MethodList::getMethodMode(sal_uInt16 index) +{ + RTMethodMode aMode = RT_MODE_INVALID; + + if (index <= m_numOfEntries) + { + aMode = (RTMethodMode) readUINT16(m_pIndex[index] + METHOD_OFFSET_MODE); + } + + return aMode; +} + +const sal_Char* MethodList::getMethodDoku(sal_uInt16 index) +{ + const sal_Char* aDoku = NULL; + + if (index <= m_numOfEntries) + { + aDoku = m_pCP->readUTF8NameConstant(readUINT16(m_pIndex[index] + METHOD_OFFSET_DOKU)); + } + + return aDoku; +} + +/************************************************************************** + + class TypeRegistryEntry + +**************************************************************************/ + +class TypeRegistryEntry : public BlopObject +{ + +public: + + ConstantPool* m_pCP; + FieldList* m_pFields; + MethodList* m_pMethods; + ReferenceList* m_pReferences; + sal_uInt32 m_refCount; + + TypeRegistryEntry(const sal_uInt8* buffer, sal_uInt32 len, sal_Bool copyBuffer) + : BlopObject(buffer, len, copyBuffer) + , m_pCP(NULL) + , m_pFields(NULL) + , m_pMethods(NULL) + , m_pReferences(NULL) + , m_refCount(1) + { + } + + ~TypeRegistryEntry(); + + void init() const; + +}; + +TypeRegistryEntry::~TypeRegistryEntry() +{ + if (m_pCP) delete m_pCP; + if (m_pFields) delete m_pFields; + if (m_pMethods) delete m_pMethods; + if (m_pReferences) delete m_pReferences; +} + + +void TypeRegistryEntry::init() const +{ +#ifdef OS2 + TypeRegistryEntry* _This = (TypeRegistryEntry*)(this); +#else + TypeRegistryEntry* _This = const_cast<TypeRegistryEntry*>(this); +#endif + + if (m_pCP) + { + delete _This->m_pCP; + _This->m_pCP = NULL; + } + + _This->m_pCP = new ConstantPool(m_pBuffer + OFFSET_CP, readUINT16(OFFSET_CP_SIZE)); + + sal_uInt32 offset = OFFSET_CP + _This->m_pCP->parseIndex(); + + _This->m_pFields = new FieldList(m_pBuffer + offset + sizeof(sal_uInt16), readUINT16(offset), _This->m_pCP); + + offset += sizeof(sal_uInt16) + _This->m_pFields->parseIndex(); + + _This->m_pMethods = new MethodList(m_pBuffer + offset + sizeof(sal_uInt16), readUINT16(offset), _This->m_pCP); + + offset += sizeof(sal_uInt16) + _This->m_pMethods->parseIndex(); + + _This->m_pReferences = new ReferenceList(m_pBuffer + offset + sizeof(sal_uInt16), readUINT16(offset), _This->m_pCP); + + offset += sizeof(sal_uInt16) + _This->m_pReferences->parseIndex(); +} + + +/************************************************************************** + + C-API + +**************************************************************************/ + +static TypeReaderImpl TYPEREG_CALLTYPE createEntry(const sal_uInt8* buffer, sal_uInt32 len, sal_Bool copyBuffer) +{ + TypeRegistryEntry* ret = NULL; + + if (len >= OFFSET_CP) + { + ret = new TypeRegistryEntry(buffer, len, copyBuffer); + + if ( + (ret->readUINT32(OFFSET_MAGIC) != magic) || + (ret->readUINT32(OFFSET_SIZE) > len) + ) + { + delete ret; + ret = NULL; + } + } + + return ret; +} + +static void TYPEREG_CALLTYPE acquire(TypeReaderImpl hEntry) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry != NULL) + pEntry->m_refCount++; +} + +static void TYPEREG_CALLTYPE release(TypeReaderImpl hEntry) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry != NULL) + { + if (--pEntry->m_refCount == 0) + delete pEntry; + } +} + +static sal_uInt16 TYPEREG_CALLTYPE getMinorVersion(TypeReaderImpl hEntry) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return 0; + + return pEntry->readUINT16(OFFSET_MINOR_VERSION); +} + +static sal_uInt16 TYPEREG_CALLTYPE getMajorVersion(TypeReaderImpl hEntry) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return 0; + + return pEntry->readUINT16(OFFSET_MAJOR_VERSION); +} + +static RTTypeClass TYPEREG_CALLTYPE getTypeClass(TypeReaderImpl hEntry) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return RT_TYPE_INVALID; + + return (RTTypeClass) pEntry->readUINT16(OFFSET_TYPE_CLASS); +} + +static void TYPEREG_CALLTYPE getTypeName(TypeReaderImpl hEntry, rtl_uString** pTypeName) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pTypeName); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(OFFSET_THIS_TYPE)); + if ( pTmp ) + rtl_string2UString( pTypeName, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static void TYPEREG_CALLTYPE getSuperTypeName(TypeReaderImpl hEntry, rtl_uString** pSuperTypeName) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pSuperTypeName); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(OFFSET_SUPER_TYPE)); + if ( pTmp ) + rtl_string2UString( pSuperTypeName, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static void TYPEREG_CALLTYPE getUik(TypeReaderImpl hEntry, RTUik* uik) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry != NULL) + { + if (pEntry->m_pCP == NULL) pEntry->init(); + + pEntry->m_pCP->readUIK(pEntry->readUINT16(OFFSET_UIK), uik); + } +} + +static void TYPEREG_CALLTYPE getDoku(TypeReaderImpl hEntry, rtl_uString** pDoku) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pDoku); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(OFFSET_DOKU)); + if ( pTmp ) + rtl_string2UString( pDoku, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static void TYPEREG_CALLTYPE getFileName(TypeReaderImpl hEntry, rtl_uString** pFileName) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pFileName); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(OFFSET_FILENAME)); + if ( pTmp ) + rtl_string2UString( pFileName, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static sal_uInt32 TYPEREG_CALLTYPE getFieldCount(TypeReaderImpl hEntry) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return 0; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pFields->m_numOfEntries; +} + +static void TYPEREG_CALLTYPE getFieldName(TypeReaderImpl hEntry, rtl_uString** pFieldName, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pFieldName); + return; + } + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pFields->getFieldName(index); + if ( pTmp ) + rtl_string2UString( pFieldName, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static void TYPEREG_CALLTYPE getFieldType(TypeReaderImpl hEntry, rtl_uString** pFieldType, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pFieldType); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pFields->getFieldType(index); + if ( pTmp ) + rtl_string2UString( pFieldType, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static RTFieldAccess TYPEREG_CALLTYPE getFieldAccess(TypeReaderImpl hEntry, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return RT_ACCESS_INVALID; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pFields->getFieldAccess(index); +} + +static RTValueType TYPEREG_CALLTYPE getFieldConstValue(TypeReaderImpl hEntry, sal_uInt16 index, RTConstValueUnion* value) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return RT_TYPE_NONE; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pFields->getFieldConstValue(index, value); +} + +static void TYPEREG_CALLTYPE getFieldDoku(TypeReaderImpl hEntry, rtl_uString** pDoku, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pDoku); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pFields->getFieldDoku(index); + if ( pTmp ) + rtl_string2UString( pDoku, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static void TYPEREG_CALLTYPE getFieldFileName(TypeReaderImpl hEntry, rtl_uString** pFieldFileName, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pFieldFileName); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pFields->getFieldFileName(index); + if ( pTmp ) + rtl_string2UString( pFieldFileName, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static sal_uInt32 TYPEREG_CALLTYPE getMethodCount(TypeReaderImpl hEntry) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return 0; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pMethods->m_numOfEntries; +} + +static void TYPEREG_CALLTYPE getMethodName(TypeReaderImpl hEntry, rtl_uString** pMethodName, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pMethodName); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pMethods->getMethodName(index); + if ( pTmp ) + rtl_string2UString( pMethodName, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static sal_uInt32 TYPEREG_CALLTYPE getMethodParamCount(TypeReaderImpl hEntry, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return 0; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pMethods->getMethodParamCount(index); +} + +static void TYPEREG_CALLTYPE getMethodParamType(TypeReaderImpl hEntry, rtl_uString** pMethodParamType, sal_uInt16 index, sal_uInt16 paramIndex) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pMethodParamType); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pMethods->getMethodParamType(index, paramIndex); + if ( pTmp ) + rtl_string2UString( pMethodParamType, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static void TYPEREG_CALLTYPE getMethodParamName(TypeReaderImpl hEntry, rtl_uString** pMethodParamName, sal_uInt16 index, sal_uInt16 paramIndex) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pMethodParamName); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pMethods->getMethodParamName(index, paramIndex); + if ( pTmp ) + rtl_string2UString( pMethodParamName, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static RTParamMode TYPEREG_CALLTYPE getMethodParamMode(TypeReaderImpl hEntry, sal_uInt16 index, sal_uInt16 paramIndex) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return RT_PARAM_INVALID; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pMethods->getMethodParamMode(index, paramIndex); +} + +static sal_uInt32 TYPEREG_CALLTYPE getMethodExcCount(TypeReaderImpl hEntry, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return 0; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pMethods->getMethodExcCount(index); +} + +static void TYPEREG_CALLTYPE getMethodExcType(TypeReaderImpl hEntry, rtl_uString** pMethodExcpType, sal_uInt16 index, sal_uInt16 excIndex) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pMethodExcpType); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pMethods->getMethodExcType(index, excIndex); + if ( pTmp ) + rtl_string2UString( pMethodExcpType, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static void TYPEREG_CALLTYPE getMethodReturnType(TypeReaderImpl hEntry, rtl_uString** pMethodReturnType, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pMethodReturnType); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pMethods->getMethodReturnType(index); + if ( pTmp ) + rtl_string2UString( pMethodReturnType, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static RTMethodMode TYPEREG_CALLTYPE getMethodMode(TypeReaderImpl hEntry, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return RT_MODE_INVALID; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pMethods->getMethodMode(index); +} + +static void TYPEREG_CALLTYPE getMethodDoku(TypeReaderImpl hEntry, rtl_uString** pMethodDoku, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pMethodDoku); + return; + } + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pMethods->getMethodDoku(index); + if ( pTmp ) + rtl_string2UString( pMethodDoku, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static sal_uInt32 TYPEREG_CALLTYPE getReferenceCount(TypeReaderImpl hEntry) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return 0; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pReferences->m_numOfEntries; +} + +static void TYPEREG_CALLTYPE getReferenceName(TypeReaderImpl hEntry, rtl_uString** pReferenceName, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pReferenceName); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pReferences->getReferenceName(index); + if ( pTmp ) + rtl_string2UString( pReferenceName, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static RTReferenceType TYPEREG_CALLTYPE getReferenceType(TypeReaderImpl hEntry, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return RT_REF_INVALID; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pReferences->getReferenceType(index); +} + +static void TYPEREG_CALLTYPE getReferenceDoku(TypeReaderImpl hEntry, rtl_uString** pReferenceDoku, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) + { + rtl_uString_new(pReferenceDoku); + return; + } + + if (pEntry->m_pCP == NULL) pEntry->init(); + + const sal_Char* pTmp = pEntry->m_pReferences->getReferenceDoku(index); + if ( pTmp ) + rtl_string2UString( pReferenceDoku, pTmp, rtl_str_getLength(pTmp), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); +} + +static RTFieldAccess TYPEREG_CALLTYPE getReferenceAccess(TypeReaderImpl hEntry, sal_uInt16 index) +{ + TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry; + + if (pEntry == NULL) return RT_ACCESS_INVALID; + + if (pEntry->m_pCP == NULL) pEntry->init(); + + return pEntry->m_pReferences->getReferenceAccess(index); +} + + +extern "C" RegistryTypeReader_Api* TYPEREG_CALLTYPE initRegistryTypeReader_Api(void) +{ + static RegistryTypeReader_Api aApi= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + if (!aApi.acquire) + { + aApi.createEntry = &createEntry; + aApi.acquire = &acquire; + aApi.release = &release; + aApi.getMinorVersion = &getMinorVersion; + aApi.getMajorVersion = &getMajorVersion; + aApi.getTypeClass = &getTypeClass; + aApi.getTypeName = &getTypeName; + aApi.getSuperTypeName = &getSuperTypeName; + aApi.getUik = &getUik; + aApi.getDoku = &getDoku; + aApi.getFileName = &getFileName; + aApi.getFieldCount = &getFieldCount; + aApi.getFieldName = &getFieldName; + aApi.getFieldType = &getFieldType; + aApi.getFieldAccess = &getFieldAccess; + aApi.getFieldConstValue = &getFieldConstValue; + aApi.getFieldDoku = &getFieldDoku; + aApi.getFieldFileName = &getFieldFileName; + aApi.getMethodCount = &getMethodCount; + aApi.getMethodName = &getMethodName; + aApi.getMethodParamCount = &getMethodParamCount; + aApi.getMethodParamType = &getMethodParamType; + aApi.getMethodParamName = &getMethodParamName; + aApi.getMethodParamMode = &getMethodParamMode; + aApi.getMethodExcCount = &getMethodExcCount; + aApi.getMethodExcType = &getMethodExcType; + aApi.getMethodReturnType = &getMethodReturnType; + aApi.getMethodMode = &getMethodMode; + aApi.getMethodDoku = &getMethodDoku; + aApi.getReferenceCount = &getReferenceCount; + aApi.getReferenceName = &getReferenceName; + aApi.getReferenceType = &getReferenceType; + aApi.getReferenceDoku = &getReferenceDoku; + aApi.getReferenceAccess = &getReferenceAccess; + + return (&aApi); + } + else + { + return (&aApi); + } +} + + + diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx new file mode 100644 index 000000000000..d8e1e2c74350 --- /dev/null +++ b/registry/source/reflwrit.cxx @@ -0,0 +1,1452 @@ +/************************************************************************* + * + * $RCSfile: reflwrit.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include <osl/types.h> + +#include <rtl/alloc.h> +#include <registry/reflwrit.hxx> + +#include "reflcnst.hxx" + +using namespace rtl; +using namespace vos; + +#ifdef MAC +#define strdup(str) strcpy((sal_Char*)malloc(strlen(str)+1),str) +#endif + +static sal_Char NULL_STRING[1] = { 0 }; +static sal_Unicode NULL_WSTRING[1] = { 0 }; + +#if defined ( GCC ) && ( defined ( SCO ) || defined ( NETBSD ) || defined ( OS2 ) ) +ORealDynamicLoader* ODynamicLoader<RegistryTypeWriter_Api>::m_pLoader = NULL; +#endif + +#define BLOP_OFFSET_MAGIC 0 +#define BLOP_OFFSET_SIZE (BLOP_OFFSET_MAGIC + sizeof(sal_uInt32)) +#define BLOP_OFFSET_MINOR (BLOP_OFFSET_SIZE + sizeof(sal_uInt32)) +#define BLOP_OFFSET_MAJOR (BLOP_OFFSET_MINOR + sizeof(sal_uInt16)) +#define BLOP_OFFSET_TYPE_CLASS (BLOP_OFFSET_MAJOR + sizeof(sal_uInt16)) +#define BLOP_OFFSET_THIS (BLOP_OFFSET_TYPE_CLASS + sizeof(sal_uInt16)) +#define BLOP_OFFSET_SUPER (BLOP_OFFSET_THIS + sizeof(sal_uInt16)) +#define BLOP_OFFSET_UIK (BLOP_OFFSET_SUPER + sizeof(sal_uInt16)) +#define BLOP_OFFSET_DOKU (BLOP_OFFSET_UIK + sizeof(sal_uInt16)) +#define BLOP_OFFSET_FILENAME (BLOP_OFFSET_DOKU + sizeof(sal_uInt16)) +#define BLOP_HEADER_SIZE (BLOP_OFFSET_FILENAME + sizeof(sal_uInt16)) + + +#define BLOP_FIELD_ENTRY_ACCESS 0 +#define BLOP_FIELD_ENTRY_NAME (BLOP_FIELD_ENTRY_ACCESS + sizeof(sal_uInt16)) +#define BLOP_FIELD_ENTRY_TYPE (BLOP_FIELD_ENTRY_NAME + sizeof(sal_uInt16)) +#define BLOP_FIELD_ENTRY_VALUE (BLOP_FIELD_ENTRY_TYPE + sizeof(sal_uInt16)) +#define BLOP_FIELD_ENTRY_DOKU (BLOP_FIELD_ENTRY_VALUE + sizeof(sal_uInt16)) +#define BLOP_FIELD_ENTRY_FILENAME (BLOP_FIELD_ENTRY_DOKU + sizeof(sal_uInt16)) +#define BLOP_FIELD_ENTRY_SIZE (BLOP_FIELD_ENTRY_FILENAME + sizeof(sal_uInt16)) + +#define BLOP_METHOD_SIZE 0 +#define BLOP_METHOD_MODE (BLOP_METHOD_SIZE + sizeof(sal_uInt16)) +#define BLOP_METHOD_NAME (BLOP_METHOD_MODE + sizeof(sal_uInt16)) +#define BLOP_METHOD_RETURN (BLOP_METHOD_NAME + sizeof(sal_uInt16)) +#define BLOP_METHOD_DOKU (BLOP_METHOD_RETURN + sizeof(sal_uInt16)) +#define BLOP_METHOD_HEADER_SIZE (BLOP_METHOD_DOKU + sizeof(sal_uInt16)) + +#define BLOP_PARAM_TYPE 0 +#define BLOP_PARAM_MODE (BLOP_PARAM_TYPE + sizeof(sal_uInt16)) +#define BLOP_PARAM_NAME (BLOP_PARAM_MODE + sizeof(sal_uInt16)) +#define BLOP_PARAM_ENTRY_SIZE (BLOP_PARAM_NAME + sizeof(sal_uInt16)) + +#define BLOP_REFERENCE_TYPE 0 +#define BLOP_REFERENCE_NAME (BLOP_REFERENCE_TYPE + sizeof(sal_uInt16)) +#define BLOP_REFERENCE_DOKU (BLOP_REFERENCE_NAME + sizeof(sal_uInt16)) +#define BLOP_REFERENCE_ACCESS (BLOP_REFERENCE_DOKU + sizeof(sal_uInt16)) +#define BLOP_REFERENCE_ENTRY_SIZE (BLOP_REFERENCE_ACCESS + sizeof(sal_uInt16)) + +sal_uInt32 UINT16StringLen(const sal_uInt8* wstring) +{ + if (!wstring) return 0; + + const sal_uInt8* b = wstring; + + while (b[0] || b[1]) b += sizeof(sal_uInt16); + + return ((b - wstring) / sizeof(sal_uInt16)); +} + +sal_uInt32 writeString(sal_uInt8* buffer, const sal_Unicode* v) +{ + sal_uInt32 len = rtl_ustr_getLength(v) + 1; + sal_uInt32 i; + sal_uInt8* buff = buffer; + + for (i = 0; i < len; i++) + { + buff += writeUINT16(buff, (sal_uInt16) v[i]); + } + + return (buff - buffer); +} + +sal_uInt32 readString(const sal_uInt8* buffer, sal_Unicode* v, sal_uInt32 maxSize) +{ + sal_uInt32 len = VOS_MIN(UINT16StringLen(buffer) + 1, maxSize / 2); + sal_uInt32 i; + sal_uInt8* buff = (sal_uInt8*)buffer; + + for (i = 0; i < (len - 1); i++) + { + sal_uInt16 aChar; + + buff += readUINT16(buff, aChar); + + v[i] = (sal_Unicode) aChar; + } + + v[len - 1] = L'\0'; + + return (buff - ((sal_uInt8*)buffer)); +} + +sal_uInt32 writeFloat(sal_uInt8* buffer, float v) +{ + union + { + float v; + sal_uInt32 b; + } x; + + x.v = v; + +#ifdef REGTYPE_IEEE_NATIVE + writeUINT32(buffer, x.b); +#else +# error no IEEE +#endif + + return sizeof(sal_uInt32); +} + +sal_uInt32 readFloat(const sal_uInt8* buffer, float& v) +{ + union + { + float v; + sal_uInt32 b; + } x; + +#ifdef REGTYPE_IEEE_NATIVE + readUINT32(buffer, x.b); +#else +# error no IEEE +#endif + + v = x.v; + + return sizeof(sal_uInt32); +} + +sal_uInt32 writeDouble(sal_uInt8* buffer, double v) +{ + union + { + double v; + struct + { + sal_uInt32 b1; + sal_uInt32 b2; + } b; + } x; + + x.v = v; + +#ifdef REGTYPE_IEEE_NATIVE +# ifdef OSL_BIGENDIAN + writeUINT32(buffer, x.b.b1); + writeUINT32(buffer + sizeof(sal_uInt32), x.b.b2); +# else + writeUINT32(buffer, x.b.b2); + writeUINT32(buffer + sizeof(sal_uInt32), x.b.b1); +# endif +#else +# error no IEEE +#endif + + return (sizeof(sal_uInt32) + sizeof(sal_uInt32)); +} + +sal_uInt32 readDouble(const sal_uInt8* buffer, double& v) +{ + union + { + double v; + struct + { + sal_uInt32 b1; + sal_uInt32 b2; + } b; + } x; + +#ifdef REGTYPE_IEEE_NATIVE +# ifdef OSL_BIGENDIAN + readUINT32(buffer, x.b.b1); + readUINT32(buffer + sizeof(sal_uInt32), x.b.b2); +# else + readUINT32(buffer, x.b.b2); + readUINT32(buffer + sizeof(sal_uInt32), x.b.b1); +# endif +#else +# error no IEEE +#endif + + v = x.v; + + return (sizeof(sal_uInt32) + sizeof(sal_uInt32)); +} + +/************************************************************************** + + buffer write functions + +**************************************************************************/ + + +/************************************************************************** + + struct CPInfo + +**************************************************************************/ + +struct CPInfo +{ + CPInfoTag m_tag; + union + { + const sal_Char* aUtf8; + RTUik* aUik; + RTConstValueUnion aConst; +/* sal_Bool aBool; + sal_uInt8 aByte; + sal_Int16 aShort; + sal_uInt16 aUShort; + sal_Int32 aLong; + sal_uInt32 aULong; +// INT64 aHyper; +// UINT64 aUHyper; + float aFloat; + double aDouble; + const sal_Unicode* aString;*/ + } m_value; + + sal_uInt16 m_index; + struct CPInfo* m_next; + + CPInfo(CPInfoTag tag, struct CPInfo* prev); + + sal_uInt32 getBlopSize(); + + sal_uInt32 toBlop(sal_uInt8* buffer, sal_uInt32 maxLen); +}; + +CPInfo::CPInfo(CPInfoTag tag, struct CPInfo* prev) + : m_tag(tag) + , m_index(0) + , m_next(NULL) +{ + if (prev) + { + m_index = prev->m_index + 1; + prev->m_next = this; + } +} + +sal_uInt32 CPInfo::getBlopSize() +{ + sal_uInt32 size = sizeof(sal_uInt16) /* size */ + sizeof(sal_uInt16) /* tag */; + + switch (m_tag) + { + case CP_TAG_CONST_BOOL: + size += sizeof(sal_uInt8); + break; + case CP_TAG_CONST_BYTE: + size += sizeof(sal_uInt8); + break; + case CP_TAG_CONST_INT16: + size += sizeof(sal_Int16); + break; + case CP_TAG_CONST_UINT16: + size += sizeof(sal_uInt16); + break; + case CP_TAG_CONST_INT32: + size += sizeof(sal_Int32); + break; + case CP_TAG_CONST_UINT32: + size += sizeof(sal_uInt32); + break; + case CP_TAG_CONST_INT64: +// size += sizeof(sal_Int64); + break; + case CP_TAG_CONST_UINT64: +// size += sizeof(sal_uInt64); + break; + case CP_TAG_CONST_FLOAT: + size += sizeof(sal_uInt32); + break; + case CP_TAG_CONST_DOUBLE: + size += sizeof(sal_uInt32) + sizeof(sal_uInt32); + break; + case CP_TAG_CONST_STRING: + size += (rtl_ustr_getLength(m_value.aConst.aString) + 1) * sizeof(sal_uInt16); + break; + case CP_TAG_UTF8_NAME: + size += strlen(m_value.aUtf8) + 1; + break; + case CP_TAG_UIK: + size += sizeof(sal_uInt32) + sizeof(sal_uInt16) + sizeof(sal_uInt16) + sizeof(sal_uInt32) + sizeof(sal_uInt32); + break; + default: + break; + } + + return size; +} + + +sal_uInt32 CPInfo::toBlop(sal_uInt8* buffer, sal_uInt32 maxLen) +{ + sal_uInt8* buff = buffer; + + buff += writeUINT16(buff, (sal_uInt16) getBlopSize()); + buff += writeUINT16(buff, (sal_uInt16) m_tag); + + switch (m_tag) + { + case CP_TAG_CONST_BOOL: + buff += writeBYTE(buff, (sal_uInt8) m_value.aConst.aBool); + break; + case CP_TAG_CONST_BYTE: + buff += writeBYTE(buff, m_value.aConst.aByte); + break; + case CP_TAG_CONST_INT16: + buff += writeINT16(buff, m_value.aConst.aShort); + break; + case CP_TAG_CONST_UINT16: + buff += writeINT16(buff, m_value.aConst.aUShort); + break; + case CP_TAG_CONST_INT32: + buff += writeINT32(buff, m_value.aConst.aLong); + break; + case CP_TAG_CONST_UINT32: + buff += writeUINT32(buff, m_value.aConst.aULong); + break; + case CP_TAG_CONST_INT64: +// buff += writeUINT64(buff, m_value.aConst.aHyper); + break; + case CP_TAG_CONST_UINT64: +// buff += writeUINT64(buff, m_value.aConst.aUHyper); + break; + case CP_TAG_CONST_FLOAT: + buff += writeFloat(buff, m_value.aConst.aFloat); + break; + case CP_TAG_CONST_DOUBLE: + buff += writeDouble(buff, m_value.aConst.aDouble); + break; + case CP_TAG_CONST_STRING: + buff += writeString(buff, m_value.aConst.aString); + break; + case CP_TAG_UTF8_NAME: + buff += writeUtf8(buff, m_value.aUtf8); + break; + case CP_TAG_UIK: + buff += writeUINT32(buff, m_value.aUik->m_Data1); + buff += writeUINT16(buff, m_value.aUik->m_Data2); + buff += writeUINT16(buff, m_value.aUik->m_Data3); + buff += writeUINT32(buff, m_value.aUik->m_Data4); + buff += writeUINT32(buff, m_value.aUik->m_Data5); + break; + default: + break; + } + + return (buff - buffer); +} + + +/************************************************************************** + + class FieldEntry + +**************************************************************************/ + +class FieldEntry +{ + +public: + + OString m_name; + OString m_typeName; + OString m_doku; + OString m_fileName; + RTFieldAccess m_access; + RTValueType m_constValueType; + RTConstValueUnion m_constValue; + + FieldEntry(); + ~FieldEntry(); + + void setData(const OString& name, + const OString& typeName, + const OString& doku, + const OString& fileName, + RTFieldAccess access, + RTValueType constValueType, + RTConstValueUnion constValue); +}; + +FieldEntry::FieldEntry() + : m_access(RT_ACCESS_INVALID) + , m_constValueType(RT_TYPE_NONE) +{ +} + +FieldEntry::~FieldEntry() +{ + if ( + (m_constValueType == RT_TYPE_STRING) && + m_constValue.aString && + (m_constValue.aString != NULL_WSTRING) + ) + { + delete[] (sal_Unicode*)m_constValue.aString; + } +} + +void FieldEntry::setData(const OString& name, + const OString& typeName, + const OString& doku, + const OString& fileName, + RTFieldAccess access, + RTValueType constValueType, + RTConstValueUnion constValue) +{ + m_name = name; + m_typeName = typeName; + m_doku = doku; + m_fileName = fileName; + + if ( + (m_constValueType == RT_TYPE_STRING) && + m_constValue.aString && + (m_constValue.aString != NULL_WSTRING) + ) + { + delete[] (sal_Unicode*)m_constValue.aString; + } + + m_access = access; + m_constValueType = constValueType; + + if (m_constValueType == RT_TYPE_STRING) + { + if (constValue.aString == NULL) + m_constValue.aString = NULL_WSTRING; + else + { + sal_uInt32 len = rtl_ustr_getLength(constValue.aString); + + m_constValue.aString = new sal_Unicode[len + 1]; + rtl_copyMemory( (sal_Unicode*)m_constValue.aString, constValue.aString, (len+1) * sizeof(sal_Unicode) ); + } + } + else + { + m_constValue = constValue; + } +} + +/************************************************************************** + + class ParamEntry + +**************************************************************************/ + +class ParamEntry +{ +public: + + OString m_typeName; + OString m_name; + RTParamMode m_mode; + + ParamEntry(); + ~ParamEntry(); + + void setData(const OString& typeName, + const OString& name, + RTParamMode mode); +}; + +ParamEntry::ParamEntry() + : m_mode(RT_PARAM_INVALID) +{ +} + +ParamEntry::~ParamEntry() +{ +} + +void ParamEntry::setData(const OString& typeName, + const OString& name, + RTParamMode mode) +{ + m_name = name; + m_typeName = typeName; + m_mode = mode; +} + +/************************************************************************** + + class ReferenceEntry + +**************************************************************************/ + +class ReferenceEntry +{ +public: + + OString m_name; + OString m_doku; + RTReferenceType m_type; + RTFieldAccess m_access; + + ReferenceEntry(); + ~ReferenceEntry(); + + void setData(const OString& name, + RTReferenceType refType, + const OString& doku, + RTFieldAccess access); +}; + +ReferenceEntry::ReferenceEntry() + : m_type(RT_REF_INVALID) + , m_access(RT_ACCESS_INVALID) +{ +} + +ReferenceEntry::~ReferenceEntry() +{ +} + +void ReferenceEntry::setData(const OString& name, + RTReferenceType refType, + const OString& doku, + RTFieldAccess access) +{ + m_name = name; + m_doku = doku; + m_type = refType; + m_access = access; +} + +/************************************************************************** + + class MethodEntry + +**************************************************************************/ + +class MethodEntry +{ +public: + + OString m_name; + OString m_returnTypeName; + RTMethodMode m_mode; + sal_uInt16 m_paramCount; + ParamEntry* m_params; + sal_uInt16 m_excCount; + OString* m_excNames; + OString m_doku; + + MethodEntry(); + ~MethodEntry(); + + void setData(const OString& name, + const OString& returnTypeName, + RTMethodMode mode, + sal_uInt16 paramCount, + sal_uInt16 excCount, + const OString& doku); + + void setExcName(sal_uInt16 excIndex, const OString& name); + +protected: + + void reallocParams(sal_uInt16 size); + void reallocExcs(sal_uInt16 size); +}; + +MethodEntry::MethodEntry() + : m_mode(RT_MODE_INVALID) + , m_paramCount(0) + , m_params(NULL) + , m_excCount(0) + , m_excNames(NULL) +{ +} + +MethodEntry::~MethodEntry() +{ + if (m_params) + delete[] m_params; + + if (m_excNames) + delete[] m_excNames; +} + +void MethodEntry::setData(const OString& name, + const OString& returnTypeName, + RTMethodMode mode, + sal_uInt16 paramCount, + sal_uInt16 excCount, + const OString& doku) +{ + m_name = name; + m_returnTypeName = returnTypeName; + m_doku = doku; + + m_mode = mode; + + reallocParams(paramCount); + reallocExcs(excCount); +} + +void MethodEntry::setExcName(sal_uInt16 excIndex, const OString& name) +{ + if (excIndex < m_excCount) + { + m_excNames[excIndex] = name; + } +} + +void MethodEntry::reallocParams(sal_uInt16 size) +{ + ParamEntry* newParams; + + if (size) + newParams = new ParamEntry[size]; + else + newParams = NULL; + + if (m_paramCount) + { + sal_uInt16 i; + + for (i = 0; i < VOS_MIN(size, m_paramCount); i++) + { + newParams[i].setData(m_params[i].m_typeName, m_params[i].m_name, m_params[i].m_mode); + } + + delete[] m_params; + } + + m_paramCount = size; + m_params = newParams; +} + +void MethodEntry::reallocExcs(sal_uInt16 size) +{ + OString* newExcNames; + + if (size) + newExcNames = new OString[size]; + else + newExcNames = NULL; + + sal_uInt16 i; + + for (i = 0; i < VOS_MIN(size, m_excCount); i++) + { + newExcNames[i] = m_excNames[i]; + } + + delete[] m_excNames; + + m_excCount = size; + m_excNames = newExcNames; +} + + +/************************************************************************** + + class TypeRegistryEntry + +**************************************************************************/ + +class TypeWriter +{ + +public: + + sal_uInt32 m_refCount; + RTTypeClass m_typeClass; + OString m_typeName; + OString m_superTypeName; + RTUik* m_pUik; + OString m_doku; + OString m_fileName; + sal_uInt16 m_fieldCount; + FieldEntry* m_fields; + sal_uInt16 m_methodCount; + MethodEntry* m_methods; + sal_uInt16 m_referenceCount; + ReferenceEntry* m_references; + + sal_uInt8* m_blop; + sal_uInt32 m_blopSize; + + TypeWriter(RTTypeClass RTTypeClass, + const OString& typeName, + const OString& superTypeName, + sal_uInt16 FieldCount, + sal_uInt16 methodCount, + sal_uInt16 referenceCount); + + ~TypeWriter(); + + void createBlop(); +}; + +TypeWriter::TypeWriter(RTTypeClass RTTypeClass, + const OString& typeName, + const OString& superTypeName, + sal_uInt16 fieldCount, + sal_uInt16 methodCount, + sal_uInt16 referenceCount) + : m_refCount(1) + , m_typeClass(RTTypeClass) + , m_typeName(typeName) + , m_superTypeName(superTypeName) + , m_fieldCount(fieldCount) + , m_methodCount(methodCount) + , m_referenceCount(referenceCount) + , m_blop(NULL) + , m_blopSize(0) + , m_pUik(NULL) +{ + if (m_fieldCount) + m_fields = new FieldEntry[fieldCount]; + + if (m_methodCount) + m_methods = new MethodEntry[methodCount]; + + if (m_referenceCount) + m_references = new ReferenceEntry[referenceCount]; +} + +TypeWriter::~TypeWriter() +{ + if (m_blop) + delete[] m_blop; + + if (m_fieldCount) + delete[] m_fields; + + if (m_methodCount) + delete[] m_methods; + + if (m_referenceCount) + delete[] m_references; + + if (m_pUik) + delete m_pUik; +} + +void TypeWriter::createBlop() +{ + sal_uInt8* pBlopFields = NULL; + sal_uInt8* pBlopMethods = NULL; + sal_uInt8* pBlopReferences = NULL; + sal_uInt8* pBuffer = NULL; + sal_uInt32 blopFieldsSize = 0; + sal_uInt32 blopMethodsSize = 0; + sal_uInt32 blopReferenceSize = 0; + sal_uInt16 i; + + if (m_blop) + delete[] m_blop; + + CPInfo root(CP_TAG_INVALID, NULL); + sal_uInt16 cpIndexThisName = 0; + sal_uInt16 cpIndexSuperName = 0; + sal_uInt16 cpIndexUik = 0; + sal_uInt16 cpIndexDoku = 0; + sal_uInt16 cpIndexFileName = 0; + CPInfo* pInfo = NULL; + + m_blopSize = BLOP_HEADER_SIZE; + + // create CP entry for this name + pInfo = new CPInfo(CP_TAG_UTF8_NAME, &root); + pInfo->m_value.aUtf8 = m_typeName.getStr(); + cpIndexThisName = pInfo->m_index; + + // create CP entry for super name + if (m_superTypeName.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_superTypeName.getStr(); + cpIndexSuperName = pInfo->m_index; + } + + // create CP entry for uik + if (m_pUik != NULL) + { + pInfo = new CPInfo(CP_TAG_UIK, pInfo); + pInfo->m_value.aUik = m_pUik; + cpIndexUik = pInfo->m_index; + } + + // create CP entry for doku + if (m_doku.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_doku.getStr(); + cpIndexDoku = pInfo->m_index; + } + + // create CP entry for idl source filename + if (m_fileName.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_fileName.getStr(); + cpIndexFileName = pInfo->m_index; + } + + // fields blop + + m_blopSize += sizeof(sal_uInt16); // fieldCount + + if (m_fieldCount) + { + sal_uInt16 cpIndexName = 0; + sal_uInt16 cpIndexTypeName = 0; + sal_uInt16 cpIndexValue = 0; + sal_uInt16 cpIndexDoku = 0; + sal_uInt16 cpIndexFileName = 0; + + blopFieldsSize = m_fieldCount * BLOP_FIELD_ENTRY_SIZE; + + m_blopSize += blopFieldsSize; + + pBlopFields = new sal_uInt8[blopFieldsSize]; + pBuffer = pBlopFields; + + for (i = 0; i < m_fieldCount; i++) + { + cpIndexName = 0; + cpIndexTypeName = 0; + cpIndexValue = 0; + cpIndexDoku = 0; + cpIndexFileName = 0; + + pBuffer += writeUINT16(pBuffer, m_fields[i].m_access); + + if (m_fields[i].m_name.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_fields[i].m_name.getStr(); + cpIndexName = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexName); + + if (m_fields[i].m_typeName.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_fields[i].m_typeName.getStr(); + cpIndexTypeName = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexTypeName); + + if (m_fields[i].m_constValueType != RT_TYPE_NONE) + { + pInfo = new CPInfo((CPInfoTag)m_fields[i].m_constValueType, pInfo); + pInfo->m_value.aConst = m_fields[i].m_constValue; + cpIndexValue = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexValue); + + if (m_fields[i].m_doku.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_fields[i].m_doku.getStr(); + cpIndexDoku = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexDoku); + + if (m_fields[i].m_fileName.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_fields[i].m_fileName.getStr(); + cpIndexFileName = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexFileName); + } + } + + // methods blop + + m_blopSize += sizeof(sal_uInt16); // methodCount + + if (m_methodCount) + { + sal_uInt16* pMethodEntrySize = new sal_uInt16[m_methodCount]; + sal_uInt16 cpIndexName = 0; + sal_uInt16 cpIndexReturn = 0; + sal_uInt16 cpIndexDoku = 0; + + blopMethodsSize = 0; + + for (i = 0; i < m_methodCount; i++) + { + pMethodEntrySize[i] = + BLOP_METHOD_HEADER_SIZE + // header + sizeof(sal_uInt16) + // parameterCount + (m_methods[i].m_paramCount * BLOP_PARAM_ENTRY_SIZE) + // exceptions + sizeof(sal_uInt16) + // exceptionCount + (m_methods[i].m_excCount * sizeof(sal_uInt16)); // exceptions + + blopMethodsSize += pMethodEntrySize[i]; + } + + pBlopMethods = new sal_uInt8[blopMethodsSize]; + + m_blopSize += blopMethodsSize; + + pBuffer = pBlopMethods; + + for (i = 0; i < m_methodCount; i++) + { + cpIndexReturn = 0; + cpIndexDoku = 0; + + pBuffer += writeUINT16(pBuffer, pMethodEntrySize[i]); + pBuffer += writeUINT16(pBuffer, m_methods[i].m_mode); + + if (m_methods[i].m_name.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_methods[i].m_name.getStr(); + cpIndexName = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexName); + cpIndexName = 0; + + if (m_methods[i].m_returnTypeName.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_methods[i].m_returnTypeName.getStr(); + cpIndexReturn = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexReturn); + + if (m_methods[i].m_doku.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_methods[i].m_doku.getStr(); + cpIndexDoku = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexDoku); + + sal_uInt16 j; + + pBuffer += writeUINT16(pBuffer, m_methods[i].m_paramCount); + + for (j = 0; j < m_methods[i].m_paramCount; j++) + { + if (m_methods[i].m_params[j].m_typeName.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_methods[i].m_params[j].m_typeName.getStr(); + cpIndexName = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexName); + cpIndexName = 0; + + pBuffer += writeUINT16(pBuffer, m_methods[i].m_params[j].m_mode); + + if (m_methods[i].m_params[j].m_name.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_methods[i].m_params[j].m_name.getStr(); + cpIndexName = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexName); + cpIndexName = 0; + } + + pBuffer += writeUINT16(pBuffer, m_methods[i].m_excCount); + + for (j = 0; j < m_methods[i].m_excCount; j++) + { + if (m_methods[i].m_excNames[j].getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_methods[i].m_excNames[j].getStr(); + cpIndexName = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexName); + cpIndexName = 0; + } + } + + delete[] pMethodEntrySize; + } + + // reference blop + + m_blopSize += sizeof(sal_uInt16); // referenceCount + + if (m_referenceCount) + { + sal_uInt16 cpIndexName = 0; + sal_uInt16 cpIndexDoku = 0; + + blopReferenceSize = m_referenceCount * BLOP_REFERENCE_ENTRY_SIZE; + + m_blopSize += blopReferenceSize; + + pBlopReferences = new sal_uInt8[blopReferenceSize]; + pBuffer = pBlopReferences; + + for (i = 0; i < m_referenceCount; i++) + { + pBuffer += writeUINT16(pBuffer, m_references[i].m_type); + + cpIndexName = 0; + cpIndexDoku = 0; + + if (m_references[i].m_name.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_references[i].m_name.getStr(); + cpIndexName = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexName); + + if (m_references[i].m_doku.getLength()) + { + pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo); + pInfo->m_value.aUtf8 = m_references[i].m_doku.getStr(); + cpIndexDoku = pInfo->m_index; + } + pBuffer += writeUINT16(pBuffer, cpIndexDoku); + + pBuffer += writeUINT16(pBuffer, m_references[i].m_access); + } + } + + + // CP infos blop-laenge holen + pInfo = root.m_next; + sal_uInt32 cpBlopSize = 0; + sal_uInt16 cpCount = 0; + + while (pInfo) + { + cpBlopSize += pInfo->getBlopSize(); + cpCount++; + pInfo = pInfo->m_next; + } + + m_blopSize += cpBlopSize; + m_blopSize += sizeof(sal_uInt16); // constantPoolCount + + // write all in flat buffer + + m_blop = new sal_uInt8[m_blopSize]; + + pBuffer = m_blop; + + pBuffer += writeUINT32(pBuffer, magic); + pBuffer += writeUINT32(pBuffer, m_blopSize); + pBuffer += writeUINT16(pBuffer, minorVersion); + pBuffer += writeUINT16(pBuffer, majorVersion); + pBuffer += writeUINT16(pBuffer, (sal_uInt16)m_typeClass); + pBuffer += writeUINT16(pBuffer, cpIndexThisName); + pBuffer += writeUINT16(pBuffer, cpIndexSuperName); + pBuffer += writeUINT16(pBuffer, cpIndexUik); + pBuffer += writeUINT16(pBuffer, cpIndexDoku); + pBuffer += writeUINT16(pBuffer, cpIndexFileName); + pBuffer += writeUINT16(pBuffer, cpCount); + + // write and delete CP infos + pInfo = root.m_next; + + while (pInfo) + { + CPInfo* pNextInfo = pInfo->m_next; + + pBuffer += pInfo->toBlop(pBuffer, m_blopSize - (pBuffer - m_blop)); + delete pInfo; + + pInfo = pNextInfo; + } + + // write fields + pBuffer += writeUINT16(pBuffer, m_fieldCount); + if (blopFieldsSize) + { + memcpy(pBuffer, pBlopFields, blopFieldsSize); + pBuffer += blopFieldsSize; + } + + // write methods + pBuffer += writeUINT16(pBuffer, m_methodCount); + if (blopMethodsSize) + { + memcpy(pBuffer, pBlopMethods, blopMethodsSize); + pBuffer += blopMethodsSize; + } + + // write references + pBuffer += writeUINT16(pBuffer, m_referenceCount); + if (blopReferenceSize) + { + memcpy(pBuffer, pBlopReferences, blopReferenceSize); + pBuffer += blopReferenceSize; + } + + delete[] pBlopFields; + delete[] pBlopMethods; + delete[] pBlopReferences; +} + + +/************************************************************************** + + C-API + +**************************************************************************/ + +static TypeWriterImpl TYPEREG_CALLTYPE createEntry(RTTypeClass RTTypeClass, + rtl_uString* typeName, + rtl_uString* superTypeName, + sal_uInt16 FieldCount, + sal_uInt16 methodCount, + sal_uInt16 referenceCount) +{ + OString rTypeName, rSuperTypeName; + + rtl_uString2String( &rTypeName.pData, typeName->buffer, typeName->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + rtl_uString2String( &rSuperTypeName.pData, superTypeName->buffer, superTypeName->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + + return new TypeWriter(RTTypeClass, + rTypeName, + rSuperTypeName, + FieldCount, + methodCount, + referenceCount); +} + +static void TYPEREG_CALLTYPE acquire(TypeWriterImpl hEntry) +{ + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if (pEntry != NULL) + pEntry->m_refCount++; +} + +static void TYPEREG_CALLTYPE release(TypeWriterImpl hEntry) +{ + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if (pEntry != NULL) + { + if (--pEntry->m_refCount == 0) + delete pEntry; + } +} + +static void TYPEREG_CALLTYPE setUik(TypeWriterImpl hEntry, const RTUik* uik) +{ + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if (pEntry != NULL) + { + if (pEntry->m_pUik) + { + pEntry->m_pUik->m_Data1 = uik->m_Data1; + pEntry->m_pUik->m_Data2 = uik->m_Data2; + pEntry->m_pUik->m_Data3 = uik->m_Data3; + pEntry->m_pUik->m_Data4 = uik->m_Data4; + pEntry->m_pUik->m_Data5 = uik->m_Data5; + } + else + pEntry->m_pUik = new RTUik(*uik); + } +} + +static void TYPEREG_CALLTYPE setDoku(TypeWriterImpl hEntry, rtl_uString* doku) +{ + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if (pEntry != NULL) + { + if (doku) + { + OString rDoku; + rtl_uString2String( &rDoku.pData, doku->buffer, doku->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + pEntry->m_doku = rDoku; + } else + { + pEntry->m_doku = NULL_STRING; + } + } +} + +static void TYPEREG_CALLTYPE setFileName(TypeWriterImpl hEntry, rtl_uString* fileName) +{ + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if (pEntry != NULL) + { + if (fileName) + { + OString rFileName; + rtl_uString2String( &rFileName.pData, fileName->buffer, fileName->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + pEntry->m_fileName = rFileName; + } else + { + pEntry->m_fileName = NULL_STRING; + } + } +} + +static void TYPEREG_CALLTYPE setFieldData(TypeWriterImpl hEntry, + sal_uInt16 index, + rtl_uString* name, + rtl_uString* typeName, + rtl_uString* doku, + rtl_uString* fileName, + RTFieldAccess access, + RTValueType valueType, + RTConstValueUnion constValue) +{ + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if ((pEntry != NULL) && (index < pEntry->m_fieldCount)) + { + OString rName, rTypeName, rDoku, rFileName; + rtl_uString2String( &rName.pData, name->buffer, name->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + rtl_uString2String( &rTypeName.pData, typeName->buffer, typeName->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + rtl_uString2String( &rDoku.pData, doku->buffer, doku->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + rtl_uString2String( &rFileName.pData, fileName->buffer, fileName->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + + pEntry->m_fields[index].setData(rName, rTypeName, rDoku, rFileName, access, valueType, constValue); + } +} + +static void TYPEREG_CALLTYPE setMethodData(TypeWriterImpl hEntry, + sal_uInt16 index, + rtl_uString* name, + rtl_uString* returnTypeName, + RTMethodMode mode, + sal_uInt16 paramCount, + sal_uInt16 excCount, + rtl_uString* doku) +{ + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if ((pEntry != NULL) && (index < pEntry->m_methodCount)) + { + OString rName, rReturnTypeName, rDoku; + rtl_uString2String( &rName.pData, name->buffer, name->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + rtl_uString2String( &rReturnTypeName.pData, returnTypeName->buffer, returnTypeName->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + rtl_uString2String( &rDoku.pData, doku->buffer, doku->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + + pEntry->m_methods[index].setData(rName, rReturnTypeName, mode, paramCount, excCount, rDoku); + } +} + +static void TYPEREG_CALLTYPE setParamData(TypeWriterImpl hEntry, + sal_uInt16 index, + sal_uInt16 paramIndex, + rtl_uString* type, + rtl_uString* name, + RTParamMode mode) +{ + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if ((pEntry != NULL) && + (index < pEntry->m_methodCount) && + (paramIndex < pEntry->m_methods[index].m_paramCount)) + { + OString rName, rType; + rtl_uString2String( &rName.pData, name->buffer, name->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + rtl_uString2String( &rType.pData, type->buffer, type->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + + pEntry->m_methods[index].m_params[paramIndex].setData(rType, rName, mode); + } +} + +static void TYPEREG_CALLTYPE setExcData(TypeWriterImpl hEntry, + sal_uInt16 index, + sal_uInt16 excIndex, + rtl_uString* type) +{ + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if ((pEntry != NULL) && (index < pEntry->m_methodCount)) + { + OString rType; + rtl_uString2String( &rType.pData, type->buffer, type->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + + pEntry->m_methods[index].setExcName(excIndex, rType); + } +} + +static const sal_uInt8* TYPEREG_CALLTYPE getBlop(TypeWriterImpl hEntry) +{ + const sal_uInt8* blop = NULL; + + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if (pEntry != NULL) + { + if (!pEntry->m_blop) + pEntry->createBlop(); + + blop = pEntry->m_blop; + } + + return blop; +} + +static sal_uInt32 TYPEREG_CALLTYPE getBlopSize(TypeWriterImpl hEntry) +{ + sal_uInt32 aSize = 0; + + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if (pEntry != NULL) + { + if (!pEntry->m_blop) + pEntry->createBlop(); + + aSize = pEntry->m_blopSize; + } + + return aSize; +} + +static void TYPEREG_CALLTYPE setReferenceData(TypeWriterImpl hEntry, + sal_uInt16 index, + rtl_uString* name, + RTReferenceType refType, + rtl_uString* doku, + RTFieldAccess access) +{ + TypeWriter* pEntry = (TypeWriter*) hEntry; + + if ((pEntry != NULL) && (index < pEntry->m_referenceCount)) + { + OString rName, rDoku; + rtl_uString2String( &rName.pData, name->buffer, name->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + rtl_uString2String( &rDoku.pData, doku->buffer, doku->length, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS); + + pEntry->m_references[index].setData(rName, + refType, + rDoku, + access); + } +} + + +extern "C" RegistryTypeWriter_Api* TYPEREG_CALLTYPE initRegistryTypeWriter_Api(void) +{ + static RegistryTypeWriter_Api aApi= {0,0,0,0,0,0,0,0,0,0,0,0,0}; + if (!aApi.acquire) + { + aApi.createEntry = &createEntry; + aApi.acquire = &acquire; + aApi.release = &release; + aApi.setUik = &setUik; + aApi.setDoku = &setDoku; + aApi.setFileName = &setFileName; + aApi.setFieldData = &setFieldData; + aApi.setMethodData = &setMethodData; + aApi.setParamData = &setParamData; + aApi.setExcData = &setExcData; + aApi.getBlop = &getBlop; + aApi.getBlopSize = &getBlopSize; + aApi.setReferenceData = &setReferenceData; + + return (&aApi); + } + else + { + return (&aApi); + } +} + + + + + diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx new file mode 100644 index 000000000000..af8c3809c51a --- /dev/null +++ b/registry/source/regimpl.cxx @@ -0,0 +1,2172 @@ +/************************************************************************* + * + * $RCSfile: regimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <string.h> +#include <stdio.h> +#ifdef MAC +#include <unistd.h> +#define strdup(str) strcpy((sal_Char*)malloc(strlen(str)+1),str) +#endif +#ifdef UNX +#include <unistd.h> +#endif + +#include "regimpl.hxx" + +#ifndef __REGISTRY_REFLREAD_HXX__ +#include <registry/reflread.hxx> +#endif + +#ifndef __REGISTRY_REFLWRIT_HXX__ +#include <registry/reflwrit.hxx> +#endif + +#ifndef __REFLCNST_HXX__ +#include "reflcnst.hxx" +#endif + +#ifndef _KEYIMPL_HXX_ +#include "keyimpl.hxx" +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + +#ifndef _RTL_MEMORY_H_ +#include <rtl/memory.h> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +#if defined ( GCC ) && ( defined ( SCO ) || defined ( NETBSD ) || defined ( OS2 ) ) +NAMESPACE_VOS(ORealDynamicLoader)* NAMESPACE_VOS(ODynamicLoader)<RegistryTypeReader_Api>::m_pLoader = NULL; +#endif + + +extern "C" RegistryTypeReader_Api* TYPEREG_CALLTYPE initRegistryTypeReader_Api(); +extern "C" RegistryTypeWriter_Api* TYPEREG_CALLTYPE initRegistryTypeWriter_Api(); + + +//********************************************************************* +// dumpType() +// +static sal_Bool dumpType(RegistryTypeReader& reader, const OString& sIndent) +{ + sal_uInt16 i, j; + sal_Bool ret = sal_True; + const sal_Char* indent = sIndent; + + if (reader.isValid()) + { + fprintf(stdout, "minor version: %d\n", reader.getMinorVersion()); + fprintf(stdout, "%smajor version: %d\n", indent, reader.getMajorVersion()); + fprintf(stdout, "%s" ,indent); + switch (reader.getTypeClass()) + { + case RT_TYPE_INVALID: + fprintf(stdout, "type: 'invalid'\n"); + break; + case RT_TYPE_INTERFACE: + { + fprintf(stdout, "type: 'interface'\n"); + RTUik uik; + + reader.getUik(uik); + + fprintf(stdout, "%suik: { 0x%.8x-0x%.4x-0x%.4x-0x%.8x-0x%.8x }\n", + indent, uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5); + } + break; + case RT_TYPE_MODULE: + fprintf(stdout, "type: 'module'\n"); + break; + case RT_TYPE_STRUCT: + fprintf(stdout, "type: 'struct'\n"); + break; + case RT_TYPE_ENUM: + fprintf(stdout, "type: 'enum'\n"); + break; + case RT_TYPE_EXCEPTION: + fprintf(stdout, "type: 'exception'\n"); + break; + case RT_TYPE_TYPEDEF: + fprintf(stdout, "type: 'typedef'\n"); + break; + case RT_TYPE_SERVICE: + fprintf(stdout, "type: 'service'\n"); + break; + case RT_TYPE_CONSTANTS: + fprintf(stdout, "type: 'constants'\n"); + break; + default: + fprintf(stdout, "type: <unknown>\n"); + break; + } + + fprintf(stdout, "%sname: '%s'\n", indent, OUStringToOString(reader.getTypeName(), RTL_TEXTENCODING_UTF8).getStr()); + fprintf(stdout, "%ssuper name: '%s'\n", indent, OUStringToOString(reader.getSuperTypeName(), RTL_TEXTENCODING_UTF8).getStr()); + fprintf(stdout, "%sDoku: \"%s\"\n", indent, OUStringToOString(reader.getDoku(), RTL_TEXTENCODING_UTF8).getStr()); + fprintf(stdout, "%sIDL source file: \"%s\"\n", indent, OUStringToOString(reader.getFileName(), RTL_TEXTENCODING_UTF8).getStr()); + fprintf(stdout, "%snumber of fields: %d\n", indent, reader.getFieldCount()); + sal_uInt16 fieldAccess = RT_ACCESS_INVALID; + for (i = 0; i < reader.getFieldCount(); i++) + { + fprintf(stdout, "%sfield #%d:\n%s name='%s'\n%s type='%s'\n", indent, + i, indent, OUStringToOString(reader.getFieldName(i), RTL_TEXTENCODING_UTF8).getStr(), + indent, OUStringToOString(reader.getFieldType(i), RTL_TEXTENCODING_UTF8).getStr()); + + fieldAccess = reader.getFieldAccess(i); + if ( fieldAccess == RT_ACCESS_INVALID ) + { + fprintf(stdout, "%s access=INVALID\n", indent); + } + if ( (fieldAccess & RT_ACCESS_CONST) == RT_ACCESS_CONST ) + { + fprintf(stdout, "%s access=CONST\n", indent); + RTConstValue constVal = reader.getFieldConstValue(i); + + fprintf(stdout, "%s value = ", indent); + + switch (constVal.m_type) + { + case RT_TYPE_BOOL: + if (constVal.m_value.aBool) + fprintf(stdout, "TRUE"); + else + fprintf(stdout, "FALSE"); + break; + case RT_TYPE_BYTE: + fprintf(stdout, "%d", (int)constVal.m_value.aByte); + break; + case RT_TYPE_INT16: + fprintf(stdout, "%d", constVal.m_value.aShort); + break; + case RT_TYPE_UINT16: + fprintf(stdout, "%u", constVal.m_value.aUShort); + break; + case RT_TYPE_INT32: + fprintf(stdout, "%d", constVal.m_value.aLong); + break; + case RT_TYPE_UINT32: + fprintf(stdout, "%u", constVal.m_value.aULong); + break; + case RT_TYPE_FLOAT: + fprintf(stdout, "%f", constVal.m_value.aFloat); + break; + case RT_TYPE_DOUBLE: + fprintf(stdout, "%f", constVal.m_value.aDouble); + break; + case RT_TYPE_STRING: + fprintf(stdout, "%s", OUStringToOString(constVal.m_value.aString, RTL_TEXTENCODING_UTF8).getStr()); + break; + default: + break; + } + } + if ( (fieldAccess & RT_ACCESS_READONLY) == RT_ACCESS_READONLY ) + { + fprintf(stdout, "%s access=READONLY\n", indent); + } + if ( (fieldAccess & RT_ACCESS_READWRITE) == RT_ACCESS_READWRITE ) + { + fprintf(stdout, "%s access=READWRITE\n", indent); + } + if ( (fieldAccess & RT_ACCESS_OPTIONAL) == RT_ACCESS_OPTIONAL ) + { + fprintf(stdout, "%s access=OPTIONAL\n", indent); + } + if ( (fieldAccess & RT_ACCESS_MAYBEVOID) == RT_ACCESS_MAYBEVOID ) + { + fprintf(stdout, "%s access=MAYBEVOID\n", indent); + } + if ( (fieldAccess & RT_ACCESS_BOUND) == RT_ACCESS_BOUND ) + { + fprintf(stdout, "%s access=BOUND\n", indent); + } + if ( (fieldAccess & RT_ACCESS_CONSTRAINED) == RT_ACCESS_CONSTRAINED ) + { + fprintf(stdout, "%s access=CONSTRAINED\n", indent); + } + if ( (fieldAccess & RT_ACCESS_TRANSIENT) == RT_ACCESS_TRANSIENT ) + { + fprintf(stdout, "%s access=TRANSIENT\n", indent); + } + if ( (fieldAccess & RT_ACCESS_MAYBEAMBIGUOUS) == RT_ACCESS_MAYBEAMBIGUOUS ) + { + fprintf(stdout, "%s access=MAYBEAMBIGUOUS\n", indent); + } + if ( (fieldAccess & RT_ACCESS_MAYBEDEFAULT) == RT_ACCESS_MAYBEDEFAULT ) + { + fprintf(stdout, "%s access=MAYBEDEFAULT\n", indent); + } + if ( (fieldAccess & RT_ACCESS_REMOVEABLE) == RT_ACCESS_REMOVEABLE ) + { + fprintf(stdout, "%s access=REMOVEABLE\n", indent); + } + +/* + switch (reader.getFieldAccess(i)) + { + case RT_ACCESS_INVALID: + fprintf(stdout, "%s access=INVALID\n", indent); + break; + case RT_ACCESS_CONST: + { + fprintf(stdout, "%s access=CONST\n", indent); + RTConstValue constVal = reader.getFieldConstValue(i); + + fprintf(stdout, "%s value = ", indent); + + switch (constVal.m_type) + { + case RT_TYPE_BOOL: + if (constVal.m_value.aBool) + fprintf(stdout, "TRUE"); + else + fprintf(stdout, "FALSE"); + break; + case RT_TYPE_BYTE: + fprintf(stdout, "%d", (int)constVal.m_value.aByte); + break; + case RT_TYPE_INT16: + fprintf(stdout, "%d", constVal.m_value.aShort); + break; + case RT_TYPE_UINT16: + fprintf(stdout, "%u", constVal.m_value.aUShort); + break; + case RT_TYPE_INT32: + fprintf(stdout, "%d", constVal.m_value.aLong); + break; + case RT_TYPE_UINT32: + fprintf(stdout, "%u", constVal.m_value.aULong); + break; + case RT_TYPE_FLOAT: + fprintf(stdout, "%f", constVal.m_value.aFloat); + break; + case RT_TYPE_DOUBLE: + fprintf(stdout, "%f", constVal.m_value.aDouble); + break; + case RT_TYPE_STRING: + fprintf(stdout, "%s", OUStringToOString(constVal.m_value.aString, RTL_TEXTENCODING_UTF8).getStr()); + break; + default: + break; + } + } + break; + case RT_ACCESS_READONLY: + fprintf(stdout, "%s access=READONLY ", indent); + break; + case RT_ACCESS_WRITEONLY: + fprintf(stdout, "%s access=WRITEONLY ", indent); + break; + case RT_ACCESS_READWRITE: + fprintf(stdout, "%s access=READWRITE ", indent); + break; + case RT_ACCESS_READONLY_OPTIONAL: + fprintf(stdout, "%s access=READONLY, OPTIONAL ", indent); + break; + case RT_ACCESS_WRITEONLY_OPTIONAL: + fprintf(stdout, "%s access=WRITEONLY, OPTIONAL ", indent); + break; + case RT_ACCESS_READWRITE_OPTIONAL: + fprintf(stdout, "%s access=READWRITE, OPTIONAL ", indent); + break; + default: + fprintf(stdout, "%s access=<unknown> ", indent); + break; + } +*/ + fprintf(stdout, "\n%s Doku: \"%s\"", indent, OUStringToOString(reader.getFieldDoku(i), RTL_TEXTENCODING_UTF8).getStr()); + fprintf(stdout, "\n%s IDL source file: \"%s\"\n", indent, OUStringToOString(reader.getFieldFileName(i), RTL_TEXTENCODING_UTF8).getStr()); + } + + fprintf(stdout, "%snumber of methods: %d\n", indent, reader.getMethodCount()); + for (i = 0; i < reader.getMethodCount(); i++) + { + fprintf(stdout, "%smethod #%d: ", indent, i); + + switch (reader.getMethodMode(i)) + { + case RT_MODE_INVALID: + fprintf(stdout, "<invalid mode> "); + break; + case RT_MODE_ONEWAY: + fprintf(stdout, "[oneway] "); + break; + case RT_MODE_ONEWAY_CONST: + fprintf(stdout, "[oneway, const] "); + break; + case RT_MODE_TWOWAY: + break; + case RT_MODE_TWOWAY_CONST: + fprintf(stdout, "[const] "); + break; + default: + fprintf(stdout, "<unknown mode> "); + break; + } + + fprintf(stdout, "%s %s(", + OUStringToOString(reader.getMethodReturnType(i), RTL_TEXTENCODING_UTF8).getStr(), + OUStringToOString(reader.getMethodName(i), RTL_TEXTENCODING_UTF8).getStr()); + + for (j = 0; j < reader.getMethodParamCount(i); j++) + { + switch (reader.getMethodParamMode(i, j)) + { + case RT_PARAM_INVALID: + fprintf(stdout, "<invalid mode> "); + break; + case RT_PARAM_IN: + fprintf(stdout, "[in] "); + break; + case RT_PARAM_OUT: + fprintf(stdout, "[out] "); + break; + case RT_PARAM_INOUT: + fprintf(stdout, "[inout] "); + break; + default: + fprintf(stdout, "<unknown mode> "); + break; + } + + fprintf(stdout, "%s %s", + OUStringToOString(reader.getMethodParamType(i, j), RTL_TEXTENCODING_UTF8).getStr(), + OUStringToOString(reader.getMethodParamName(i, j), RTL_TEXTENCODING_UTF8).getStr()); + + if (j != reader.getMethodParamCount(i) - 1) + fprintf(stdout, ", "); + } + + fprintf(stdout, ") "); + + if (reader.getMethodExcCount(i)) + { + fprintf(stdout, "raises "); + for (j = 0; j < reader.getMethodExcCount(i); j++) + { + fprintf(stdout, "%s", + OUStringToOString(reader.getMethodExcType(i, j), RTL_TEXTENCODING_UTF8).getStr()); + if (j != reader.getMethodExcCount(i) - 1) + fprintf(stdout, ", "); + } + } + + fprintf(stdout, "\n%s Doku: \"%s\"\n", indent, + OUStringToOString(reader.getMethodDoku(i), RTL_TEXTENCODING_UTF8).getStr()); + } + + fprintf(stdout, "%snumber of references: %d\n", indent, reader.getReferenceCount()); + for (i = 0; i < reader.getReferenceCount(); i++) + { + fprintf(stdout, "%sreference #%d:\n%s name='%s'\n", indent, i, indent, + OUStringToOString(reader.getReferenceName(i), RTL_TEXTENCODING_UTF8).getStr()); + switch (reader.getReferenceType(i)) + { + case RT_REF_INVALID: + fprintf(stdout, "%s type=INVALID\n", indent); + break; + case RT_REF_SUPPORTS: + { + fprintf(stdout, "%s type=supported interface\n", indent); + if (reader.getReferenceAccess(i) == RT_ACCESS_OPTIONAL) + { + fprintf(stdout, "%s access=optional\n", indent); + } + } + break; + case RT_REF_OBSERVES: + fprintf(stdout, "%s type=observed interface\n", indent); + break; + case RT_REF_EXPORTS: + fprintf(stdout, "%s type=exported service\n", indent); + break; + case RT_REF_NEEDS: + fprintf(stdout, "%s type=needed service\n", indent); + break; + default: + fprintf(stdout, "%s type=<unknown>\n", indent); + break; + } + + fprintf(stdout, "%s Doku: \"%s\"\n", indent, + OUStringToOString(reader.getReferenceDoku(i), RTL_TEXTENCODING_UTF8).getStr()); + } + } + else + { + ret = sal_False; + } + + return ret; +} + + +//********************************************************************* +// ORegistry() +// +ORegistry::ORegistry() + : m_refCount(1) + , m_readOnly(sal_False) + , m_isOpen(sal_False) + , ROOT( RTL_CONSTASCII_USTRINGPARAM("/") ) +{ +} + +//********************************************************************* +// ~ORegistry() +// +ORegistry::~ORegistry() +{ + if (m_openKeyTable.count(ROOT) > 0) + { + m_openKeyTable[ROOT]->release(); + delete(m_openKeyTable[ROOT]); + } + + if (m_file.isValid()) + m_file.close(); +} + + +//********************************************************************* +// initRegistry +// +RegError ORegistry::initRegistry(const OUString& regName, RegAccessMode accessMode) +{ + OStoreFile rRegFile; + storeAccessMode sAccessMode = REG_MODE_OPEN; + storeError errCode; + + if (accessMode & REG_CREATE) + { + sAccessMode = REG_MODE_CREATE; + } else + if (accessMode & REG_READONLY) + { + sAccessMode = REG_MODE_OPENREAD; + m_readOnly = sal_True; + } + + if (errCode = rRegFile.create(regName, sAccessMode, REG_PAGESIZE)) + { + switch (errCode) + { + case store_E_NotExists: + return REG_REGISTRY_NOT_EXISTS; + break; + case store_E_LockingViolation: + return REG_CANNOT_OPEN_FOR_READWRITE; + break; + default: + return REG_INVALID_REGISTRY; + break; + } + } else + { + OStoreDirectory rStoreDir; + storeError _err = rStoreDir.create(rRegFile, OUString(), OUString(), sAccessMode); + + if ( _err == store_E_None ) + { + m_file = rRegFile; + m_name = regName; + m_isOpen = sal_True; + + + m_openKeyTable[ROOT] = new ORegKey(ROOT, rStoreDir, this); + return REG_NO_ERROR; + } else + return REG_INVALID_REGISTRY; + } +} + + +//********************************************************************* +// closeRegistry +// +RegError ORegistry::closeRegistry() +{ + REG_GUARD(m_mutex); + + if (m_file.isValid()) + { + closeKey(m_openKeyTable[ROOT]); + m_file.close(); + m_isOpen = sal_False; + return REG_NO_ERROR; + } else + { + return REG_REGISTRY_NOT_EXISTS; + } +} + + +//********************************************************************* +// destroyRegistry +// +RegError ORegistry::destroyRegistry(const OUString& regName) +{ + REG_GUARD(m_mutex); + + if (regName.getLength()) + { + ORegistry* pReg = new ORegistry(); + + if (!pReg->initRegistry(regName, REG_READWRITE)) + { + delete pReg; + + OString name( OUStringToOString(regName, RTL_TEXTENCODING_UTF8) ); + if (unlink(name) != 0) + { + return REG_DESTROY_REGISTRY_FAILED; + } + } else + { + return REG_DESTROY_REGISTRY_FAILED; + } + } else + { + if (m_refCount != 1 || isReadOnly()) + { + return REG_DESTROY_REGISTRY_FAILED; + } + + if (m_file.isValid()) + { + closeKey(m_openKeyTable[ROOT]); + m_file.close(); + m_isOpen = sal_False; + + OString name( OUStringToOString(m_name, RTL_TEXTENCODING_UTF8) ); + if (unlink(name) != 0) + { + return REG_DESTROY_REGISTRY_FAILED; + } + } else + { + return REG_REGISTRY_NOT_EXISTS; + } + } + + return REG_NO_ERROR; +} + +//********************************************************************* +// createKey +// +RegError ORegistry::createKey(RegKeyHandle hKey, const OUString& keyName, + RegKeyHandle* phNewKey) +{ + ORegKey* pKey; + + *phNewKey = NULL; + + if ( !keyName.getLength() ) + return REG_INVALID_KEYNAME; + + REG_GUARD(m_mutex); + + if (hKey) + pKey = (ORegKey*)hKey; + else + pKey = m_openKeyTable[ROOT]; + + OUString sFullKeyName = resolveLinks(pKey, keyName); + + if ( !sFullKeyName.getLength() ) + return REG_DETECT_RECURSION; + + if (m_openKeyTable.count(sFullKeyName) > 0) + { + *phNewKey = m_openKeyTable[sFullKeyName]; + ((ORegKey*)*phNewKey)->acquire(); + ((ORegKey*)*phNewKey)->setDeleted(sal_False); + return REG_NO_ERROR; + } + + OStoreDirectory rStoreDir; + OUStringBuffer sFullPath(sFullKeyName.getLength()); + sal_Int32 tokenCount = sFullKeyName.getTokenCount('/'); + OUString token; + + sFullPath.append((sal_Unicode)'/'); + + for (sal_Int32 i=0; i < tokenCount; i++) + { + token = sFullKeyName.getToken(i, '/'); + if (token.getLength()) + { + if (rStoreDir.create(pKey->getStoreFile(), sFullPath.getStr(), token, KEY_MODE_CREATE)) + { + return REG_CREATE_KEY_FAILED; + } + + sFullPath.append(token); + sFullPath.append((sal_Unicode)'/'); + } + } + + pKey = new ORegKey(sFullKeyName, rStoreDir, this); + *phNewKey = pKey; + m_openKeyTable[sFullKeyName] = pKey; + + return REG_NO_ERROR; +} + + +//********************************************************************* +// openKey +// +RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName, + RegKeyHandle* phOpenKey, RESOLVE eResolve) +{ + ORegKey* pKey; + storeAccessMode accessMode = KEY_MODE_OPEN; + + *phOpenKey = NULL; + + if ( !keyName.getLength() ) + { + return REG_INVALID_KEYNAME; + } + + if ( isReadOnly() ) + { + accessMode = KEY_MODE_OPENREAD; + } + + REG_GUARD(m_mutex); + + if (hKey) + pKey = (ORegKey*)hKey; + else + pKey = m_openKeyTable[ROOT]; + + OUString sFullKeyName; + OUString sFullPath; + OUString sRelativKey; + + switch (eResolve) + { + case RESOLVE_FULL: + { + sFullKeyName = resolveLinks(pKey, keyName); + + if ( !sFullKeyName.getLength() ) + return REG_DETECT_RECURSION; + + sal_Int32 lastIndex = sFullKeyName.lastIndexOf('/'); + sRelativKey = sFullKeyName.copy(lastIndex + 1); + sFullPath = sFullKeyName.copy(0, lastIndex + 1); + } + break; + case RESOLVE_PART: + { + sal_Int32 lastIndex = keyName.lastIndexOf('/'); + if ( lastIndex >= 0 ) + { + OUString sRelativ(keyName.copy(lastIndex)); + OUString tmpKey(keyName.copy(0, lastIndex + 1)); + sFullKeyName = resolveLinks(pKey, tmpKey); + + sFullPath = sFullKeyName; + sFullPath += ROOT; + sFullKeyName += sRelativ; + sRelativKey = sRelativ.copy(1); + } else + { + sFullKeyName = pKey->getName(); + sFullPath = sFullKeyName; + + sRelativKey = keyName; + + if ( sFullKeyName.getLength() > 1 ) + sFullKeyName += ROOT; + + sFullKeyName += keyName; + + if ( sFullPath.getLength() > 1 ) + sFullPath += ROOT; + } + } + break; + case RESOLVE_NOTHING: + { + sFullKeyName = pKey->getName(); + sFullPath = sFullKeyName; + + if (sFullKeyName.getLength() > 1) + sFullKeyName += ROOT; + + sal_Int32 lastIndex = keyName.lastIndexOf('/'); + if ( lastIndex >= 0 && lastIndex < keyName.getLength() ) + { + OUString sRelativ(keyName.copy(lastIndex+1)); + sRelativKey = sRelativ; + sFullKeyName += keyName.copy(1); + + sFullPath = sFullKeyName.copy(0, keyName.lastIndexOf('/') + 1); + } else + { + + sRelativKey += keyName; + sFullKeyName += keyName; + + if ( sFullPath.getLength() > 1 ) + sFullPath += ROOT; + } + } + break; + } + + if (m_openKeyTable.count(sFullKeyName) > 0) + { + m_openKeyTable[sFullKeyName]->acquire(); + *phOpenKey = m_openKeyTable[sFullKeyName]; + return REG_NO_ERROR; + } + + OStoreDirectory rStoreDir; + storeError _err = rStoreDir.create(pKey->getStoreFile(), sFullPath, sRelativKey, accessMode); + + if (_err == store_E_NotExists) + return REG_KEY_NOT_EXISTS; + else + if (_err == store_E_WrongFormat) + return REG_INVALID_KEY; + + pKey = new ORegKey(sFullKeyName, rStoreDir, this); + + *phOpenKey = pKey; + m_openKeyTable[sFullKeyName] = pKey; + + return REG_NO_ERROR; +} + + +//********************************************************************* +// closeKey +// +RegError ORegistry::closeKey(RegKeyHandle hKey) +{ + ORegKey* pKey = (ORegKey*)hKey; + + REG_GUARD(m_mutex); + + if (m_openKeyTable.count(pKey->getName()) > 0) + { + if (pKey->getRefCount() == 1) + { + m_openKeyTable.erase(pKey->getName()); + delete(pKey); + hKey = NULL; + } else + { + pKey->release(); + } + + return REG_NO_ERROR; + } else + { + return REG_KEY_NOT_OPEN; + } +} + + +//********************************************************************* +// deleteKey +// +RegError ORegistry::deleteKey(RegKeyHandle hKey, const OUString& keyName) +{ + ORegKey* pKey; + RegError _ret = REG_NO_ERROR; + + if ( !keyName.getLength() ) + { + return REG_INVALID_KEYNAME; + } + + REG_GUARD(m_mutex); + + if (hKey) + pKey = (ORegKey*)hKey; + else + pKey = m_openKeyTable[ROOT]; + + OUString sFullKeyName = resolveLinks(pKey, keyName); + + if ( !sFullKeyName.getLength() ) + return REG_DETECT_RECURSION; + + pKey = m_openKeyTable[ROOT]; + _ret = eraseKey(pKey, sFullKeyName, RESOLVE_NOTHING); + + return _ret; +} + +RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName, RESOLVE eResolve) +{ + RegError _ret = REG_NO_ERROR; + + if ( !keyName.getLength() ) + { + return REG_INVALID_KEYNAME; + } + + OUString sFullKeyName(pKey->getName()); + OUString sFullPath(sFullKeyName); + OUString sRelativKey; + sal_Int32 lastIndex = keyName.lastIndexOf('/'); + + if ( lastIndex >= 0 ) + { + sRelativKey += keyName.copy(lastIndex + 1); + + if (sFullKeyName.getLength() > 1) + sFullKeyName += keyName; + else + sFullKeyName += (keyName+1); + + sFullPath = sFullKeyName.copy(0, keyName.lastIndexOf('/') + 1); + } else + { + if (sFullKeyName.getLength() > 1) + sFullKeyName += ROOT; + + sRelativKey += keyName; + sFullKeyName += keyName; + + if (sFullPath.getLength() > 1) + sFullPath += ROOT; + } + + RegKeyHandle hOldKey; + if (_ret = pKey->openKey(keyName, &hOldKey, eResolve)) + { + return _ret; + } + + if (_ret = deleteSubkeysAndValues((ORegKey*)hOldKey, eResolve)) + { + pKey->closeKey(hOldKey); + return _ret; + } + + OUString tmpName(sRelativKey); + tmpName += ROOT; + + OStoreFile sFile(pKey->getStoreFile()); + + if ( sFile.isValid() && sFile.remove(sFullPath, tmpName) ) + { + return REG_DELETE_KEY_FAILED; + } + + // set flag deleted !!! + ((ORegKey*)hOldKey)->setDeleted(sal_True); + + if (_ret = pKey->closeKey(hOldKey)) + { + return _ret; + } + + return REG_NO_ERROR; +} + + +//********************************************************************* +// deleteSubKeys +// +RegError ORegistry::deleteSubkeysAndValues(ORegKey* pKey, RESOLVE eResolve) +{ + OStoreDirectory::iterator iter; + OUString keyName; + RegError _ret = REG_NO_ERROR; + OStoreDirectory rStoreDir(pKey->getStoreDir()); + storeError _err = rStoreDir.first(iter); + + while ( _err == store_E_None ) + { + keyName = iter.m_pszName; + + if (iter.m_nAttrib & STORE_ATTRIB_ISDIR) + { + if ((_ret = eraseKey(pKey, keyName, eResolve))) + return _ret; + } else + { + OUString sFullPath(pKey->getName()); + + if (sFullPath.getLength() > 1) + sFullPath += ROOT; + + if ( ((OStoreFile&)pKey->getStoreFile()).remove(sFullPath, keyName) ) + { + return REG_DELETE_VALUE_FAILED; + } + } + + _err = rStoreDir.next(iter); + } + + return REG_NO_ERROR; +} + + +//********************************************************************* +// loadKey +// +RegError ORegistry::loadKey(RegKeyHandle hKey, const OUString& regFileName, + sal_Bool bWarnings, sal_Bool bReport) +{ + RegError _ret = REG_NO_ERROR; + ORegistry* pReg; + ORegKey *pKey, *pRootKey; + + pReg = new ORegistry(); + if (_ret = pReg->initRegistry(regFileName, REG_READONLY)) + { + return _ret; + } + + pKey = (ORegKey*)hKey; + pRootKey = pReg->getRootKey(); + + REG_GUARD(m_mutex); + + OStoreDirectory::iterator iter; + OUString keyName; + OStoreDirectory rStoreDir(pRootKey->getStoreDir()); + storeError _err = rStoreDir.first(iter); + + while ( _err == store_E_None ) + { + keyName = iter.m_pszName; + + if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR ) + { + _ret = loadAndSaveKeys(pKey, pRootKey, keyName, 0, bWarnings, bReport); + } else + { + _ret = loadAndSaveValue(pKey, pRootKey, keyName, 0, bWarnings, bReport); + } + + if (_ret == REG_MERGE_ERROR || + (_ret == REG_MERGE_CONFLICT && bWarnings)) + { + rStoreDir = OStoreDirectory(); + pRootKey->release(); + delete(pReg); + return _ret; + } + + _err = rStoreDir.next(iter); + } + + rStoreDir = OStoreDirectory(); + pRootKey->release(); + delete(pReg); + return _ret; +} + + +//********************************************************************* +// loadKey +// +RegError ORegistry::saveKey(RegKeyHandle hKey, const OUString& regFileName, + sal_Bool bWarnings, sal_Bool bReport) +{ + RegError _ret = REG_NO_ERROR; + ORegistry* pReg; + ORegKey *pKey, *pRootKey; + + pReg = new ORegistry(); + if (_ret = pReg->initRegistry(regFileName, REG_CREATE)) + { + return _ret; + } + + pKey = (ORegKey*)hKey; + pRootKey = pReg->getRootKey(); + + REG_GUARD(m_mutex); + + OStoreDirectory::iterator iter; + OUString keyName; + OStoreDirectory rStoreDir(pKey->getStoreDir()); + storeError _err = rStoreDir.first(iter); + + while ( _err == store_E_None ) + { + keyName = iter.m_pszName; + + if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR ) + { + _ret = loadAndSaveKeys(pRootKey, pKey, keyName, + pKey->getName().getLength(), + bWarnings, bReport); + } else + { + _ret = loadAndSaveValue(pRootKey, pKey, keyName, + pKey->getName().getLength(), + bWarnings, bReport); + } + + if (_ret) + { + pRootKey->release(); + delete(pReg); + return _ret; + } + + _err = rStoreDir.next(iter); + } + + pRootKey->release(); + delete(pReg); + return REG_NO_ERROR; +} + + +//********************************************************************* +// isKeyOpen() +// +sal_Bool ORegistry::isKeyOpen(const OUString& keyName) const +{ + return(m_openKeyTable.count(keyName) > 0); +} + + + +//********************************************************************* +// countSubKeys() +// +sal_uInt32 ORegistry::countSubKeys(ORegKey* pKey) +{ + REG_GUARD(m_mutex); + + OStoreDirectory::iterator iter; + sal_uInt32 count = 0; + OStoreDirectory rStoreDir(pKey->getStoreDir()); + storeError _err = rStoreDir.first(iter); + + while ( _err == store_E_None) + { + if (iter.m_nAttrib & STORE_ATTRIB_ISDIR) + { + count++; + } + + _err = rStoreDir.next(iter); + } + + return count; +} + + +//********************************************************************* +// loadValue() +// +RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey, + ORegKey* pSourceKey, + const OUString& valueName, + sal_uInt32 nCut, + sal_Bool bWarnings, + sal_Bool bReport) +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + RegValueType valueType; + sal_uInt32 valueSize; + sal_uInt32 nSize; + storeAccessMode sourceAccess = VALUE_MODE_OPEN; + OUString sTargetPath(pTargetKey->getName()); + OUString sSourcePath(pSourceKey->getName()); + + if (pSourceKey->isReadOnly()) + { + sourceAccess = VALUE_MODE_OPENREAD; + } + + if (nCut) + { + sTargetPath = sSourcePath.copy(nCut); + } else + { + if (sTargetPath.getLength() > 1) + { + if (sSourcePath.getLength() > 1) + sTargetPath += sSourcePath; + } else + sTargetPath = sSourcePath; + } + + if (sTargetPath.getLength() > 1) sTargetPath += ROOT; + if (sSourcePath.getLength() > 1) sSourcePath += ROOT; + + if (rValue.create(pSourceKey->getStoreFile(), sSourcePath, valueName, sourceAccess)) + { + return REG_VALUE_NOT_EXISTS; + } + + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); + + sal_uInt32 rwBytes; + if (rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, rwBytes)) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (rwBytes != VALUE_HEADERSIZE) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + RegError _ret = REG_NO_ERROR; + sal_uInt8 type = *((sal_uInt8*)pBuffer); + valueType = (RegValueType)type; + readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize); + rtl_freeMemory(pBuffer); + + nSize = VALUE_HEADERSIZE + valueSize; + pBuffer = (sal_uInt8*)rtl_allocateMemory(nSize); + + if (rValue.readAt(0, pBuffer, nSize, rwBytes)) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (rwBytes != nSize) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + OStoreFile rTargetFile(pTargetKey->getStoreFile()); + + if (!rValue.create(rTargetFile, sTargetPath, valueName, VALUE_MODE_OPEN)) + { + if (valueType == RG_VALUETYPE_BINARY) + { + if (_ret = checkBlop(rValue, pTargetKey, sTargetPath, + valueName, valueSize, pBuffer+VALUE_HEADEROFFSET, + bReport)) + { + if (_ret == REG_MERGE_ERROR || + (_ret == REG_MERGE_CONFLICT && bWarnings)) + { + rtl_freeMemory(pBuffer); + return _ret; + } + } else + { + rtl_freeMemory(pBuffer); + return _ret; + } + } + } + + // write + if (rValue.create(rTargetFile, sTargetPath, valueName, VALUE_MODE_CREATE)) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (rValue.writeAt(0, pBuffer, nSize, rwBytes)) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + if (rwBytes != nSize) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + rtl_freeMemory(pBuffer); + return _ret; +} + + +//********************************************************************* +// checkblop() +// +RegError ORegistry::checkBlop(OStoreStream& rValue, + ORegKey* pTargetKey, + const OUString& sTargetPath, + const OUString& valueName, + sal_uInt32 srcValueSize, + sal_uInt8* pSrcBuffer, + sal_Bool bReport) +{ + RegistryTypeReader_Api* pReaderApi; + + pReaderApi = initRegistryTypeReader_Api(); + + RegistryTypeReader reader(pReaderApi, pSrcBuffer, srcValueSize, sal_False); + + if (reader.getTypeClass() == RT_TYPE_INVALID) + { + return REG_INVALID_VALUE; + } + + sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); + RegValueType valueType; + sal_uInt32 valueSize; + sal_uInt32 rwBytes; + OString targetPath( OUStringToOString(sTargetPath, RTL_TEXTENCODING_UTF8) ); + + if (!rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, rwBytes) && + (rwBytes == VALUE_HEADERSIZE)) + { + sal_uInt8 type = *((sal_uInt8*)pBuffer); + valueType = (RegValueType)type; + readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize); + rtl_freeMemory(pBuffer); + + if (valueType == RG_VALUETYPE_BINARY) + { + pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize); + if (!rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, rwBytes) && + (rwBytes == valueSize)) + { + RegistryTypeReader reader2(pReaderApi, pBuffer, valueSize, sal_False); + + if ((reader.getTypeClass() != reader2.getTypeClass()) + || reader2.getTypeClass() == RT_TYPE_INVALID) + { + rtl_freeMemory(pBuffer); + + if (bReport) + { + fprintf(stdout, "ERROR: values of blop from key \"%s\" has different types.\n", + targetPath.getStr()); + } + return REG_MERGE_ERROR; + } + + if (reader.getTypeClass() == RT_TYPE_MODULE) + { + if (reader.getFieldCount() > 0 && + reader2.getFieldCount() > 0) + { + mergeModuleValue(rValue, pTargetKey, sTargetPath, + valueName, reader, reader2); + + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; + } else + if (reader2.getFieldCount() > 0) + { + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; + } else + { + rtl_freeMemory(pBuffer); + return REG_MERGE_CONFLICT; + } + } else + { + rtl_freeMemory(pBuffer); + + if (bReport) + { + fprintf(stdout, "WARNING: value of key \"%s\" already exists.\n", + targetPath.getStr()); + } + return REG_MERGE_CONFLICT; + } + } else + { + rtl_freeMemory(pBuffer); + if (bReport) + { + fprintf(stdout, "ERROR: values of key \"%s\" contains bad data.\n", + targetPath.getStr()); + } + return REG_MERGE_ERROR; + } + } else + { + rtl_freeMemory(pBuffer); + if (bReport) + { + fprintf(stdout, "ERROR: values of key \"%s\" has different types.\n", + targetPath.getStr()); + } + return REG_MERGE_ERROR; + } + } else + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } +} + +static sal_uInt32 checkTypeReaders(RegistryTypeReader& reader1, + RegistryTypeReader& reader2, + StringSet& nameSet) +{ + sal_uInt32 count=0; + sal_uInt32 i; + for (i=0 ; i < reader1.getFieldCount(); i++) + { + nameSet.insert(reader1.getFieldName(i)); + count++; + } + for (i=0 ; i < reader2.getFieldCount(); i++) + { + if (nameSet.find(reader2.getFieldName(i)) == nameSet.end()) + { + nameSet.insert(reader2.getFieldName(i)); + count++; + } + } + return count; +} + +//********************************************************************* +// mergeModuleValue() +// +RegError ORegistry::mergeModuleValue(OStoreStream& rTargetValue, + ORegKey* pTargetKey, + const OUString& sTargetPath, + const OUString& valueName, + RegistryTypeReader& reader, + RegistryTypeReader& reader2) +{ + sal_uInt16 index = 0; + RegistryTypeWriter_Api* pWriterApi; + + StringSet nameSet; + sal_uInt32 count = checkTypeReaders(reader, reader2, nameSet); + + if (count != reader.getFieldCount()) + { + pWriterApi = initRegistryTypeWriter_Api(); + + RegistryTypeWriter writer(pWriterApi, + reader.getTypeClass(), + reader.getTypeName(), + reader.getSuperTypeName(), + count, + 0, + 0); + + int i; + for (i=0 ; i < reader.getFieldCount(); i++) + { + writer.setFieldData(index, + reader.getFieldName(i), + reader.getFieldType(i), + reader.getFieldDoku(i), + reader.getFieldFileName(i), + reader.getFieldAccess(i), + reader.getFieldConstValue(i)); + index++; + } + for (i=0 ; i < reader2.getFieldCount(); i++) + { + if (nameSet.find(reader2.getFieldName(i)) == nameSet.end()) + { + writer.setFieldData(index, + reader2.getFieldName(i), + reader2.getFieldType(i), + reader2.getFieldDoku(i), + reader2.getFieldFileName(i), + reader2.getFieldAccess(i), + reader2.getFieldConstValue(i)); + index++; + } + } + + const sal_uInt8* pBlop = writer.getBlop(); + sal_uInt32 aBlopSize = writer.getBlopSize(); + + sal_uInt8 type = (sal_uInt8)RG_VALUETYPE_BINARY; + sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE + aBlopSize); + + rtl_copyMemory(pBuffer, &type, 1); + writeUINT32(pBuffer+VALUE_TYPEOFFSET, aBlopSize); + rtl_copyMemory(pBuffer+VALUE_HEADEROFFSET, pBlop, aBlopSize); + + sal_uInt32 rwBytes; + if (rTargetValue.writeAt(0, pBuffer, VALUE_HEADERSIZE+aBlopSize, rwBytes)) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + if (rwBytes != VALUE_HEADERSIZE+aBlopSize) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + rtl_freeMemory(pBuffer); + } + return REG_NO_ERROR; +} + +//********************************************************************* +// loadKeys() +// +RegError ORegistry::loadAndSaveKeys(ORegKey* pTargetKey, + ORegKey* pSourceKey, + const OUString& keyName, + sal_uInt32 nCut, + sal_Bool bWarnings, + sal_Bool bReport) +{ + ORegKey* pTmpKey; + RegError _ret = REG_NO_ERROR; + OUString sRelPath(pSourceKey->getName().copy(nCut)); + OUString sFullPath; + + if(pTargetKey->getName().getLength() > 1) + sFullPath += pTargetKey->getName(); + sFullPath += sRelPath; + if (sRelPath.getLength() > 1 || sFullPath.getLength() == 0) + sFullPath += ROOT; + + OUString sFullKeyName = sFullPath; + OStoreDirectory rStoreDir; + + sFullKeyName += keyName; + + if (rStoreDir.create(pTargetKey->getStoreFile(), sFullPath, keyName, KEY_MODE_CREATE)) + { + return REG_CREATE_KEY_FAILED; + } + + if (m_openKeyTable.count(sFullKeyName) > 0) + { + m_openKeyTable[sFullKeyName]->setDeleted(sal_False); + } + + + if (_ret = pSourceKey->openKey(keyName, (RegKeyHandle*)&pTmpKey, RESOLVE_NOTHING)) + { + return _ret; + } + + OStoreDirectory::iterator iter; + OUString sName; + OStoreDirectory rTmpStoreDir(pTmpKey->getStoreDir()); + storeError _err = rTmpStoreDir.first(iter); + + while ( _err == store_E_None) + { + sName = iter.m_pszName; + + if (iter.m_nAttrib & STORE_ATTRIB_ISDIR) + { + _ret = loadAndSaveKeys(pTargetKey, pTmpKey, + sName, nCut, bWarnings, bReport); + } else + { + _ret = loadAndSaveValue(pTargetKey, pTmpKey, + sName, nCut, bWarnings, bReport); + } + + if (_ret == REG_MERGE_ERROR || + (_ret == REG_MERGE_CONFLICT && bWarnings)) + { + pSourceKey->closeKey(pTmpKey); + return _ret; + } + + _err = rTmpStoreDir.next(iter); + } + + pSourceKey->closeKey(pTmpKey); + return _ret; +} + + +//********************************************************************* +// getRootKey() +// +ORegKey* ORegistry::getRootKey() +{ + m_openKeyTable[ROOT]->acquire(); + return m_openKeyTable[ROOT]; +} + + +//********************************************************************* +// getResolvedKeyName() +// +RegError ORegistry::getResolvedKeyName(RegKeyHandle hKey, + const OUString& keyName, + OUString& resolvedName, + sal_Bool firstLinkOnly) +{ + ORegKey* pKey; + + if ( !keyName.getLength() ) + return REG_INVALID_KEYNAME; + + REG_GUARD(m_mutex); + + if (hKey) + pKey = (ORegKey*)hKey; + else + pKey = m_openKeyTable[ROOT]; + + resolvedName = resolveLinks(pKey, keyName, firstLinkOnly); + + if ( resolvedName.getLength() ) + return REG_NO_ERROR; + else + return REG_DETECT_RECURSION; +} + +//********************************************************************* +// dumpRegistry() +// +RegError ORegistry::dumpRegistry(RegKeyHandle hKey) const +{ + ORegKey *pKey = (ORegKey*)hKey; + OUString sName; + RegError _ret = REG_NO_ERROR; + OStoreDirectory::iterator iter; + OStoreDirectory rStoreDir(pKey->getStoreDir()); + storeError _err = rStoreDir.first(iter); + + OString regName( OUStringToOString( getName(), RTL_TEXTENCODING_UTF8 ) ); + OString keyName( OUStringToOString( pKey->getName(), RTL_TEXTENCODING_UTF8 ) ); + fprintf(stdout, "Registry \"%s\":\n\n%s\n", regName.getStr(), keyName.getStr()); + + while ( _err == store_E_None ) + { + sName = iter.m_pszName; + + if (iter.m_nAttrib & STORE_ATTRIB_ISDIR) + { + _ret = dumpKey(pKey->getName(), sName, 1); + } else + { + _ret = dumpValue(pKey->getName(), sName, 1); + } + + if (_ret) + { + return _ret; + } + + _err = rStoreDir.next(iter); + } + + return REG_NO_ERROR; +} + + +//********************************************************************* +// dumpValue() +// +RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_Int16 nSpc) const +{ + OStoreStream rValue; + sal_uInt8* pBuffer; + sal_uInt32 valueSize; + RegValueType valueType; + OUString sFullPath(sPath); + OString sIndent; + storeAccessMode accessMode = VALUE_MODE_OPEN; + sal_Bool bLinkValue = sal_False; + + if (isReadOnly()) + { + accessMode = VALUE_MODE_OPENREAD; + } + + for (int i= 0; i < nSpc; i++) sIndent += " "; + + if (sFullPath.getLength() > 1) + { + sFullPath += ROOT; + } + if (rValue.create(m_file, sFullPath, sName, accessMode)) + { + return REG_VALUE_NOT_EXISTS; + } + + OUString tmpName( RTL_CONSTASCII_USTRINGPARAM(VALUE_PREFIX) ); + tmpName += OUString( RTL_CONSTASCII_USTRINGPARAM("LINK_TARGET") ); + if (sName == tmpName) + { + bLinkValue = sal_True; + } + pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); + + sal_uInt32 rwBytes; + if (rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, rwBytes)) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (rwBytes != (VALUE_HEADERSIZE)) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + sal_uInt8 type = *((sal_uInt8*)pBuffer); + valueType = (RegValueType)type; + readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize); + + pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize); + if (rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, rwBytes)) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + if (rwBytes != valueSize) + { + rtl_freeMemory(pBuffer); + return REG_INVALID_VALUE; + } + + const sal_Char* indent = sIndent.getStr(); + switch (valueType) + { + case 0: + fprintf(stdout, "%sValue: Type = VALUETYPE_NOT_DEFINED\n", indent); + break; + case 1: + { + fprintf(stdout, "%sValue: Type = RG_VALUETYPE_LONG\n", indent); + fprintf(stdout, "%s Size = %d\n", indent, valueSize); + fprintf(stdout, "%s Data = ", indent); + + sal_Int32 value; + readINT32(pBuffer, value); + fprintf(stdout, "%d\n", value); + } + break; + case 2: + { + sal_Char* value = (sal_Char*)rtl_allocateMemory(valueSize); + readUtf8(pBuffer, value, valueSize); + + if (bLinkValue) + { + fprintf(stdout, "%sKEY: Type = RG_LINKTYPE\n", indent); + fprintf(stdout, "%s LinkTarget = \"%s\"\n", indent, value); + } else + { + fprintf(stdout, "%sValue: Type = RG_VALUETYPE_STRING\n", indent); + fprintf(stdout, "%s Size = %d\n", indent, valueSize); + fprintf(stdout, "%s Data = \"%s\"\n", indent, value); + } + + rtl_freeMemory(value); + } + break; + case 3: + { + sal_uInt32 size = (valueSize / 2) * sizeof(sal_Unicode); + fprintf(stdout, "%sValue: Type = RG_VALUETYPE_UNICODE\n", indent); + fprintf(stdout, "%s Size = %d\n", indent, valueSize); + fprintf(stdout, "%s Data = ", indent); + + sal_Unicode* value = new sal_Unicode[size]; + readString(pBuffer, value, size); + + OString uStr = OUStringToOString(value, RTL_TEXTENCODING_UTF8); + fprintf(stdout, "L\"%s\"\n", uStr.getStr()); + delete[] value; + } + break; + case 4: + { + fprintf(stdout, "%sValue: Type = RG_VALUETYPE_BINARY\n", indent); + fprintf(stdout, "%s Size = %d\n", indent, valueSize); + fprintf(stdout, "%s Data = ", indent); + + RegistryTypeReader_Api* pReaderApi; + + pReaderApi = initRegistryTypeReader_Api(); + + RegistryTypeReader reader(pReaderApi, pBuffer, valueSize, sal_False); + + sIndent += " "; + if (!dumpType(reader, sIndent)) + { + fprintf(stdout, "<unknown>\n"); + } + + } + break; + case 5: + { + sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays + sal_uInt32 len = 0; + + readUINT32(pBuffer, len); + + fprintf(stdout, "%sValue: Type = RG_VALUETYPE_LONGLIST\n", indent); + fprintf(stdout, "%s Size = %d\n", indent, valueSize); + fprintf(stdout, "%s Len = %d\n", indent, len); + fprintf(stdout, "%s Data = ", indent); + + sal_Int32 longValue; + for (int i=0; i < len; i++) + { + readINT32(pBuffer+offset, longValue); + + if (offset > 4) + fprintf(stdout, "%s ", indent); + + fprintf(stdout, "%d = %d\n", i, longValue); + offset += 4; // 4 Bytes fuer sal_Int32 + } + } + break; + case 6: + { + sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays + sal_uInt32 sLen = 0; + sal_uInt32 len = 0; + + readUINT32(pBuffer, len); + + fprintf(stdout, "%sValue: Type = RG_VALUETYPE_STRINGLIST\n", indent); + fprintf(stdout, "%s Size = %d\n", indent, valueSize); + fprintf(stdout, "%s Len = %d\n", indent, len); + fprintf(stdout, "%s Data = ", indent); + + sal_Char *pValue; + for (int i=0; i < len; i++) + { + readUINT32(pBuffer+offset, sLen); + + offset += 4; // 4 Bytes (sal_uInt32) fuer die Groesse des strings in Bytes + + pValue = (sal_Char*)rtl_allocateMemory(sLen); + readUtf8(pBuffer+offset, pValue, sLen); + + if (offset > 8) + fprintf(stdout, "%s ", indent); + + fprintf(stdout, "%d = \"%s\"\n", i, pValue); + offset += sLen; + } + } + break; + case 7: + { + sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays + sal_uInt32 sLen = 0; + sal_uInt32 len = 0; + + readUINT32(pBuffer, len); + + fprintf(stdout, "%sValue: Type = RG_VALUETYPE_UNICODELIST\n", indent); + fprintf(stdout, "%s Size = %d\n", indent, valueSize); + fprintf(stdout, "%s Len = %d\n", indent, len); + fprintf(stdout, "%s Data = ", indent); + + sal_Unicode *pValue; + OString uStr; + for (int i=0; i < len; i++) + { + readUINT32(pBuffer+offset, sLen); + + offset += 4; // 4 Bytes (sal_uInt32) fuer die Groesse des strings in Bytes + + pValue = (sal_Unicode*)rtl_allocateMemory((sLen / 2) * sizeof(sal_Unicode)); + readString(pBuffer+offset, pValue, sLen); + + if (offset > 8) + fprintf(stdout, "%s ", indent); + + uStr = OUStringToOString(pValue, RTL_TEXTENCODING_UTF8); + fprintf(stdout, "%d = L\"%s\"\n", i, uStr.getStr()); + + offset += sLen; + + rtl_freeMemory(pValue); + } + } + break; + } + + fprintf(stdout, "\n"); + + rtl_freeMemory(pBuffer); + return REG_NO_ERROR; +} + +//********************************************************************* +// dumpKey() +// +RegError ORegistry::dumpKey(const OUString& sPath, const OUString& sName, sal_Int16 nSpace) const +{ + OStoreDirectory rStoreDir; + OUString sFullPath(sPath); + OString sIndent; + storeAccessMode accessMode = KEY_MODE_OPEN; + RegError _ret = REG_NO_ERROR; + + if (isReadOnly()) + { + accessMode = KEY_MODE_OPENREAD; + } + + for (int i= 0; i < nSpace; i++) sIndent += " "; + + if (sFullPath.getLength() > 1) + sFullPath += ROOT; + + storeError _err = rStoreDir.create(m_file, sFullPath, sName, accessMode); + + if (_err == store_E_NotExists) + return REG_KEY_NOT_EXISTS; + else + if (_err == store_E_WrongFormat) + return REG_INVALID_KEY; + + fprintf(stdout, "%s/ %s\n", sIndent.getStr(), OUStringToOString(sName, RTL_TEXTENCODING_UTF8).getStr()); + + OUString sSubPath(sFullPath); + OUString sSubName; + sSubPath += sName; + + OStoreDirectory::iterator iter; + + _err = rStoreDir.first(iter); + + while ( _err == store_E_None) + { + sSubName = iter.m_pszName; + + if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR ) + { + _ret = dumpKey(sSubPath, sSubName, nSpace+2); + } else + { + _ret = dumpValue(sSubPath, sSubName, nSpace+2); + } + + if (_ret) + { + return _ret; + } + + _err = rStoreDir.next(iter); + } + + return REG_NO_ERROR; +} + +//********************************************************************* +// createLink() +// +RegError ORegistry::createLink(RegKeyHandle hKey, + const OUString& linkName, + const OUString& linkTarget) +{ + ORegKey* pKey; + + if ( !linkName.getLength() ) + { + return REG_INVALID_LINKNAME; + } + + REG_GUARD(m_mutex); + + if (hKey) + pKey = (ORegKey*)hKey; + else + pKey = m_openKeyTable[ROOT]; + + OUString sFullLinkName = resolveLinks(pKey, linkName, sal_True); + + if (sFullLinkName.getLength() == 0) + return REG_DETECT_RECURSION; + + OStoreDirectory rStoreDir; + OUString sFullPath(ROOT); + + sal_uInt32 tokenCount = sFullLinkName.getTokenCount('/'); + sal_uInt32 actToken = 0; + OUString token; + + token = sFullLinkName.getToken(actToken, '/'); + + while ( actToken < tokenCount && token.getLength() > 0 ) + { + if (rStoreDir.create(pKey->getStoreFile(), sFullPath, token, KEY_MODE_CREATE)) + { + return REG_CREATE_KEY_FAILED; + } + + sFullPath += token; + sFullPath += ROOT; + + token = sFullLinkName.getToken(++actToken, '/'); + } + + pKey = new ORegKey(sFullLinkName, linkTarget, rStoreDir, this); + delete pKey; + + return REG_NO_ERROR; +} + +//********************************************************************* +// deleteLink() +// +RegError ORegistry::deleteLink(RegKeyHandle hKey, const OUString& linkName) +{ + ORegKey* pKey; + + if ( !linkName.getLength() ) + { + return REG_INVALID_LINKNAME; + } + + REG_GUARD(m_mutex); + + if (hKey) + pKey = (ORegKey*)hKey; + else + pKey = m_openKeyTable[ROOT]; + + OUString tmpPath(linkName); + OUString tmpName; + OUString resolvedPath; + sal_Int32 lastIndex = tmpPath.lastIndexOf('/'); + + if ( lastIndex > 0 && tmpPath.getStr()[0] == '/') + { + tmpName = tmpPath.copy(lastIndex); + + OUString linkPath = tmpPath.copy(0, lastIndex); + + resolvedPath = resolveLinks(pKey, linkPath); + + if ( !resolvedPath.getLength() ) + { + return REG_DETECT_RECURSION; + } + + resolvedPath += tmpName; + } else + { + resolvedPath = pKey->getName(); + + if (lastIndex != 0 && resolvedPath.getLength() > 1) + resolvedPath += ROOT; + + resolvedPath += linkName; + } + + pKey = m_openKeyTable[ROOT]; + + RegKeyType keyType; + RegError ret = REG_NO_ERROR; + if (ret = pKey->getKeyType(resolvedPath, &keyType)) + return ret; + + if (keyType != RG_LINKTYPE) + return REG_INVALID_LINK; + + return eraseKey(pKey, resolvedPath, RESOLVE_PART); +} + +//********************************************************************* +// resolveLinks() +// +OUString ORegistry::resolveLinks(ORegKey* pKey, const OUString& path, sal_Bool firstLinkOnly) +{ + OUString resolvedPath(pKey->getName()); + sal_uInt32 tokenCount = path.getTokenCount('/'); + sal_uInt32 actToken = 0; + OUString token; + ORegKey* pLink = NULL; + + if (resolvedPath.getLength() > 1) + resolvedPath += ROOT; + + if ( path.getStr()[0] == '/' ) + token = path.getToken(++actToken, '/'); + else + token = path.getToken(actToken, '/'); + + while ( actToken < tokenCount && token.getLength() > 0 ) + { + pLink = resolveLink(pKey, resolvedPath, token); + + if (pLink) + { + OUString tmpName; + sal_Int32 lastIndex; + + while(pLink) + { + if (!insertRecursionLink(pLink)) + { + resetRecursionLinks(); + delete pLink; + return OUString(); + } + + + lastIndex = resolvedPath.lastIndexOf('/'); + tmpName = resolvedPath.copy(lastIndex + 1); + resolvedPath = resolvedPath.copy(0, lastIndex + 1); + + pLink = resolveLink(pKey, resolvedPath, tmpName); + } + + resetRecursionLinks(); + } + + token = path.getToken(++actToken, '/'); + if ( token.getLength() ) + resolvedPath += ROOT; + } + + return resolvedPath; +} + +//********************************************************************* +// resolveLink() +// +ORegKey* ORegistry::resolveLink(ORegKey* pKey, OUString& resolvedPath, const OUString& name) +{ + OStoreDirectory rStoreDir; + ORegKey* pTmpKey = NULL; + + if ( !rStoreDir.create(pKey->getStoreFile(), resolvedPath, + name, KEY_MODE_OPENREAD) ) + { + resolvedPath += name; + pTmpKey = new ORegKey(resolvedPath, rStoreDir, pKey->getRegistry()); + RegKeyType keyType; + sal_Bool bIsLink=sal_False; + if (!pTmpKey->getKeyType(OUString(), &keyType) && (keyType == RG_LINKTYPE)) + { + resolvedPath = pTmpKey->getLinkTarget(); + return pTmpKey; + } + + delete pTmpKey; + return NULL; + } else + { + resolvedPath += name; + return NULL; + } +} + +sal_Bool ORegistry::insertRecursionLink(ORegKey* pLink) +{ + if (m_recursionList.empty()) + { + m_recursionList.push_back(pLink); + } else + { + LinkList::iterator iter = m_recursionList.begin(); + + while (iter != m_recursionList.end()) + { + if ((*iter)->getName() == pLink->getName()) + return sal_False; + + iter++; + } + m_recursionList.push_back(pLink); + } + + return sal_True; +} + +sal_Bool ORegistry::resetRecursionLinks() +{ + LinkList::iterator iter = m_recursionList.begin(); + + while (iter != m_recursionList.end()) + { + delete *iter; + iter++; + } + + m_recursionList.erase(m_recursionList.begin(), m_recursionList.end()); + + return sal_True; +} + + diff --git a/registry/source/regimpl.hxx b/registry/source/regimpl.hxx new file mode 100644 index 000000000000..458766bafe17 --- /dev/null +++ b/registry/source/regimpl.hxx @@ -0,0 +1,266 @@ +/************************************************************************* + * + * $RCSfile: regimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _REGIMPL_HXX_ +#define _REGIMPL_HXX_ + +#include <registry/registry.h> + +#ifndef _REGMAP_HXX_ +#include "regmap.hxx" +#endif + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _STORE_STORE_HXX_ +#include <store/store.hxx> +#endif + +#define REG_PAGESIZE 512 + +#define REG_MODE_CREATE store_AccessCreate +#define REG_MODE_OPEN store_AccessReadWrite +#define REG_MODE_OPENREAD store_AccessReadOnly + +#define KEY_MODE_CREATE store_AccessCreate +#define KEY_MODE_OPEN store_AccessReadWrite +#define KEY_MODE_OPENREAD store_AccessReadOnly + + +#define VALUE_MODE_CREATE store_AccessCreate +#define VALUE_MODE_OPEN store_AccessReadWrite +#define VALUE_MODE_OPENREAD store_AccessReadOnly + +#define VALUE_PREFIX "$VL_" +#define VALUE_LINKTARGET "$VL_LINK_TARGET" + +// 5 Bytes = 1 (Byte fuer den Typ) + 4 (Bytes fuer die Groesse der Daten) +#define VALUE_HEADERSIZE 5 +#define VALUE_TYPEOFFSET 1 +#define VALUE_HEADEROFFSET 5 + +#define REG_CREATE 0x0004 // allow write accesses + +#define REG_GUARD(mutex) \ + Guard< Mutex > aGuard( mutex ); + +using namespace rtl; +using namespace osl; +using namespace store; + +enum RESOLVE +{ + // alle Links werden aufgeloest + RESOLVE_FULL, + // alles bis zum letzten TeilStueck wird aufgeloest + RESOLVE_PART, + // kein Link wird aufgeloest + RESOLVE_NOTHING +}; + +class ORegManager; +class RegistryTypeReader; + +class ORegistry +{ +public: + ORegistry(); + + sal_uInt32 acquire() + { return ++m_refCount; } + + sal_uInt32 release() + { return --m_refCount; } + + RegError initRegistry(const OUString& name, + RegAccessMode accessMode); + + RegError closeRegistry(); + + RegError destroyRegistry(const OUString& name); + + RegError createKey(RegKeyHandle hKey, + const OUString& keyName, + RegKeyHandle* phNewKey); + + RegError openKey(RegKeyHandle hKey, + const OUString& keyName, + RegKeyHandle* phOpenKey, + RESOLVE eResolve=RESOLVE_FULL); + + RegError closeKey(RegKeyHandle hKey); + + RegError deleteKey(RegKeyHandle hKey, const OUString& keyName); + + RegError loadKey(RegKeyHandle hKey, + const OUString& regFileName, + sal_Bool bWarings=sal_False, + sal_Bool bReport=sal_False); + + RegError saveKey(RegKeyHandle hKey, + const OUString& regFileName, + sal_Bool bWarings=sal_False, + sal_Bool bReport=sal_False); + + RegError dumpRegistry(RegKeyHandle hKey) const; + + RegError createLink(RegKeyHandle hKey, + const OUString& linkName, + const OUString& linkTarget); + + RegError deleteLink(RegKeyHandle hKey, + const OUString& linkName); + +public: + virtual ~ORegistry(); + + sal_Bool isKeyOpen(const OUString& keyName) const; + sal_Bool isReadOnly() const + { return m_readOnly; } + + sal_Bool isOpen() const + { return m_isOpen; } + + ORegKey* getRootKey(); + + const OStoreFile& getStoreFile() + { return m_file; } + + const OUString& getName() const + { return m_name; } + + RegError getResolvedKeyName(RegKeyHandle hKey, + const OUString& keyName, + OUString& resolvedName, + sal_Bool firstLinkOnly=sal_False); + + friend class ORegKey; +protected: + RegError eraseKey(ORegKey* pKey, + const OUString& keyName, + RESOLVE eResolve=RESOLVE_FULL); + + RegError deleteSubkeysAndValues(ORegKey* pKey, + RESOLVE eResolve=RESOLVE_FULL); + + sal_uInt32 countSubKeys(ORegKey* pKey); + + RegError loadAndSaveValue(ORegKey* pTargetKey, + ORegKey* pSourceKey, + const OUString& valueName, + sal_uInt32 nCut, + sal_Bool bWarnings=sal_False, + sal_Bool bReport=sal_False); + + RegError checkBlop(OStoreStream& rValue, + ORegKey* pTargetKey, + const OUString& sTargetPath, + const OUString& valueName, + sal_uInt32 srcValueSize, + sal_uInt8* pSrcBuffer, + sal_Bool bReport=sal_False); + + RegError mergeModuleValue(OStoreStream& rTargetValue, + ORegKey* pTargetKey, + const OUString& sTargetPath, + const OUString& valueName, + RegistryTypeReader& reader, + RegistryTypeReader& reader2); + + RegError loadAndSaveKeys(ORegKey* pTargetKey, + ORegKey* pSourceKey, + const OUString& keyName, + sal_uInt32 nCut, + sal_Bool bWarnings=sal_False, + sal_Bool bReport=sal_False); + + RegError dumpValue(const OUString& sPath, + const OUString& sName, + sal_Int16 nSpace) const; + + RegError dumpKey(const OUString& sPath, + const OUString& sName, + sal_Int16 nSpace) const; + + OUString resolveLinks(ORegKey* pKey, const OUString& path, sal_Bool firstLinkOnly=sal_False); + ORegKey* resolveLink(ORegKey* pKey, OUString& resolvedPath, const OUString& name); + + sal_Bool insertRecursionLink(ORegKey* pLink); + sal_Bool resetRecursionLinks(); + +protected: + + sal_uInt32 m_refCount; + Mutex m_mutex; + sal_Bool m_readOnly; + sal_Bool m_isOpen; + OUString m_name; + OStoreFile m_file; + KeyMap m_openKeyTable; + LinkList m_recursionList; + + const OUString ROOT; +}; + +#endif + diff --git a/registry/source/registry.cxx b/registry/source/registry.cxx new file mode 100644 index 000000000000..1e6f4af4335b --- /dev/null +++ b/registry/source/registry.cxx @@ -0,0 +1,793 @@ +/************************************************************************* + * + * $RCSfile: registry.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <registry/registry.h> + +#ifndef _REGISTRY_REGISTRY_HXX_ +#include <registry/registry.hxx> +#endif + +#ifndef _REGIMPL_HXX_ +#include "regimpl.hxx" +#endif + +#ifndef _REGKEY_HXX_ +#include "keyimpl.hxx" +#endif + +#include <vos/process.hxx> + +#if defined(WIN32) || defined(WNT) || defined(__OS2__) +#include <io.h> +#endif + +#if defined(UNX) +#include <stdlib.h> +#include <unistd.h> +#endif + +using namespace vos; + +#if defined ( GCC ) && ( defined ( SCO ) || defined ( NETBSD ) ) +ORealDynamicLoader* ODynamicLoader<Registry_Api>::m_pLoader = NULL; +#endif + +OString getTempName() +{ + OUString uTmpPattern; + sal_Char tmpPattern[512] = ""; + sal_Char *pTmpName = NULL; + + OStartupInfo StartupInfo; + + if (StartupInfo.getEnvironment(OUString( RTL_CONSTASCII_USTRINGPARAM("TMP") ), + uTmpPattern) != OStartupInfo::E_None) + { + if (StartupInfo.getEnvironment( OUString( RTL_CONSTASCII_USTRINGPARAM("TEMP") ), + uTmpPattern) != NAMESPACE_VOS(OStartupInfo)::E_None) + { +#if defined(WIN32) || defined(WNT) || defined(OS2) + strcpy(tmpPattern, "."); +#else + strcpy(tmpPattern, "/tmp"); +#endif + } + } + + if ( uTmpPattern.getLength() ) + { + strcpy(tmpPattern, OUStringToOString(uTmpPattern, RTL_TEXTENCODING_UTF8).getStr()); + } + +#if defined(WIN32) || defined(WNT) + strcat(tmpPattern, "\\reg_XXXXXX"); + pTmpName = mktemp(tmpPattern); +#endif + +#ifdef __OS2__ + strcpy(tmpPattern, tempnam(NULL, "reg_")); + pTmpName = tmpPattern; +#endif + +#ifdef UNX + strcat(tmpPattern, "/reg_XXXXXX"); + pTmpName = mktemp(tmpPattern); +#endif + + return OString(pTmpName); +} + +//********************************************************************* +// acquire +// +static void REGISTRY_CALLTYPE acquire(RegHandle hReg) +{ + ORegistry* pReg = (ORegistry*) hReg; + + if (pReg != NULL) + pReg->acquire(); +} + + +//********************************************************************* +// release +// +static void REGISTRY_CALLTYPE release(RegHandle hReg) +{ + ORegistry* pReg = (ORegistry*) hReg; + + if (pReg) + { + if (pReg->release() == 0) + { + delete pReg; + hReg = NULL; + } + } +} + + +//********************************************************************* +// getName +// +static RegError REGISTRY_CALLTYPE getName(RegHandle hReg, rtl_uString** pName) +{ + ORegistry* pReg; + + if (hReg) + { + pReg = (ORegistry*)hReg; + if ( pReg->isOpen() ) + { + rtl_uString_assign(pName, pReg->getName().pData); + return REG_NO_ERROR; + } else + { + rtl_uString_new(pName); + return REG_REGISTRY_NOT_OPEN; + } + } + + rtl_uString_new(pName); + return REG_INVALID_REGISTRY; +} + + +//********************************************************************* +// isReadOnly +// +static sal_Bool REGISTRY_CALLTYPE isReadOnly(RegHandle hReg) +{ + if (hReg) + return ((ORegistry*)hReg)->isReadOnly(); + else + return sal_False; +} + + +//********************************************************************* +// createRegistry +// +static RegError REGISTRY_CALLTYPE createRegistry(rtl_uString* registryName, + RegHandle* phRegistry) +{ + RegError ret; + + ORegistry* pReg = new ORegistry(); + if (ret = pReg->initRegistry(registryName, REG_CREATE)) + { + *phRegistry = NULL; + return ret; + } + + *phRegistry = pReg; + + return REG_NO_ERROR; +} + +//********************************************************************* +// openRootKey +// +static RegError REGISTRY_CALLTYPE openRootKey(RegHandle hReg, + RegKeyHandle* phRootKey) +{ + ORegistry* pReg; + + if (hReg) + { + pReg = (ORegistry*)hReg; + if (!pReg->isOpen()) + return REG_REGISTRY_NOT_OPEN; + } else + { + phRootKey = NULL; + return REG_INVALID_REGISTRY; + } + + *phRootKey = pReg->getRootKey(); + + return REG_NO_ERROR; +} + + +//********************************************************************* +// openRegistry +// +static RegError REGISTRY_CALLTYPE openRegistry(rtl_uString* registryName, + RegHandle* phRegistry, + RegAccessMode accessMode) +{ + RegError _ret; + + ORegistry* pReg = new ORegistry(); + if (_ret = pReg->initRegistry(registryName, accessMode)) + { + *phRegistry = NULL; + delete pReg; + return _ret; + } + + + *phRegistry = pReg; + + return REG_NO_ERROR; +} + +//********************************************************************* +// closeRegistry +// +static RegError REGISTRY_CALLTYPE closeRegistry(RegHandle hReg) +{ + ORegistry *pReg; + + if (hReg) + { + pReg = (ORegistry*)hReg; + if (!pReg->isOpen()) + return REG_REGISTRY_NOT_OPEN; + + RegError ret = REG_NO_ERROR; + if (pReg->release() == 0) + { + delete(pReg); + hReg = NULL; + } + else + ret = pReg->closeRegistry(); + + return ret; + } else + { + return REG_INVALID_REGISTRY; + } +} + + +//********************************************************************* +// destroyRegistry +// +static RegError REGISTRY_CALLTYPE destroyRegistry(RegHandle hReg, + rtl_uString* registryName) +{ + ORegistry *pReg; + + if (hReg) + { + pReg = (ORegistry*)hReg; + if (!pReg->isOpen()) + return REG_INVALID_REGISTRY; + + RegError ret = REG_NO_ERROR; + if (!(ret = pReg->destroyRegistry(registryName))) + { + if (!registryName->length) + { + delete(pReg); + hReg = NULL; + } + } + return ret; + } else + { + return REG_INVALID_REGISTRY; + } +} + + +//********************************************************************* +// loadRegKey +// +static RegError REGISTRY_CALLTYPE loadKey(RegHandle hReg, + RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName) +{ + ORegistry *pReg; + ORegKey *pKey, *pNewKey; + RegError _ret; + + if (hReg) + { + pReg = (ORegistry*)hReg; + if (!pReg->isOpen()) + return REG_REGISTRY_NOT_OPEN; + } else + { + return REG_INVALID_REGISTRY; + } + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->getRegistry() != pReg || pKey->isDeleted()) + return REG_INVALID_KEY; + } else + { + return REG_INVALID_KEY; + } + + if (pKey->isReadOnly()) + return REG_REGISTRY_READONLY; + + if (!pKey->openKey(keyName, (RegKeyHandle*)&pNewKey)) + { + pKey->closeKey(pNewKey); + pKey->deleteKey(keyName); + } + + if (_ret = pKey->createKey(keyName, (RegKeyHandle*)&pNewKey)) + return _ret; + + if (_ret = pReg->loadKey(pNewKey, regFileName)) + { + pKey->closeKey(pNewKey); + pKey->deleteKey(keyName); + return _ret; + } + + return pKey->closeKey(pNewKey); +} + +//********************************************************************* +// saveKey +// +static RegError REGISTRY_CALLTYPE saveKey(RegHandle hReg, + RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName) +{ + ORegistry *pReg; + ORegKey *pKey, *pNewKey; + RegError _ret; + + if (hReg) + { + pReg = (ORegistry*)hReg; + if (!pReg->isOpen()) + return REG_REGISTRY_NOT_OPEN; + } else + { + return REG_INVALID_REGISTRY; + } + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->getRegistry() != pReg || pKey->isDeleted()) + return REG_INVALID_KEY; + } else + { + return REG_INVALID_KEY; + } + + if (_ret = pKey->openKey(keyName, (RegKeyHandle*)&pNewKey)) + return _ret; + + if (_ret = pReg->saveKey(pNewKey, regFileName)) + { + pKey->closeKey(pNewKey); + return _ret; + } + + return pKey->closeKey(pNewKey); +} + +//********************************************************************* +// mergeKey +// +static RegError REGISTRY_CALLTYPE mergeKey(RegHandle hReg, + RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName, + sal_Bool bWarnings, + sal_Bool bReport) +{ + ORegistry *pReg; + ORegKey *pKey, *pNewKey; + RegError _ret; + + if (hReg) + { + pReg = (ORegistry*)hReg; + if (!pReg->isOpen()) + return(REG_REGISTRY_NOT_OPEN); + } else + { + return REG_INVALID_REGISTRY; + } + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->getRegistry() != pReg || pKey->isDeleted()) + return REG_INVALID_KEY; + } else + { + return REG_INVALID_KEY; + } + + if (pKey->isReadOnly()) + return REG_REGISTRY_READONLY; + + if (keyName->length) + { + if (_ret = pKey->createKey(keyName, (RegKeyHandle*)&pNewKey) ) + return _ret; + } else + { + pNewKey = pKey; + } + + /* + OString tmpName = getTempName(); + pReg->saveKey(pNewKey, tmpName, sal_False, sal_False); + */ + _ret = pKey->getRegistry()->loadKey(pNewKey, regFileName, bWarnings, bReport); + /* + if (_ret) + { + if (_ret == REG_MERGE_ERROR || + (_ret == REG_MERGE_CONFLICT && bWarnings)) + { + pKey->closeKey(pNewKey); + pKey->deleteKey(keyName); + pKey->createKey(keyName, (RegKeyHandle*)&pNewKey); + pReg->loadKey(pNewKey, tmpName, sal_False, sal_False); + } + + destroyRegistry(hReg, tmpName); + + pKey->closeKey(pNewKey); + return _ret; + } + + destroyRegistry(hReg, tmpName); + */ + if ( pKey != pNewKey ) + _ret = pKey->closeKey(pNewKey); + + return _ret; +} + + +//********************************************************************* +// dumpRegistry +// +static RegError REGISTRY_CALLTYPE dumpRegistry(RegHandle hReg, + RegKeyHandle hKey) +{ + ORegistry *pReg; + ORegKey *pKey; + + if (hReg) + { + pReg = (ORegistry*)hReg; + if (!pReg->isOpen()) + return REG_REGISTRY_NOT_OPEN; + } else + { + return REG_INVALID_REGISTRY; + } + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->getRegistry() != pReg || pKey->isDeleted()) + return REG_INVALID_KEY; + } else + { + return REG_INVALID_KEY; + } + + return pReg->dumpRegistry(hKey); +} + + +//********************************************************************* +// initRegistry_Api +// +void REGISTRY_CALLTYPE acquireKey(RegKeyHandle); +void REGISTRY_CALLTYPE releaseKey(RegKeyHandle); +sal_Bool REGISTRY_CALLTYPE isKeyReadOnly(RegKeyHandle); +RegError REGISTRY_CALLTYPE getKeyName(RegKeyHandle, rtl_uString**); +RegError REGISTRY_CALLTYPE createKey(RegKeyHandle, rtl_uString*, RegKeyHandle*); +RegError REGISTRY_CALLTYPE openKey(RegKeyHandle, rtl_uString*, RegKeyHandle*); +RegError REGISTRY_CALLTYPE openSubKeys(RegKeyHandle, rtl_uString*, RegKeyHandle**, sal_uInt32*); +RegError REGISTRY_CALLTYPE closeSubKeys(RegKeyHandle*, sal_uInt32); +RegError REGISTRY_CALLTYPE deleteKey(RegKeyHandle, rtl_uString*); +RegError REGISTRY_CALLTYPE closeKey(RegKeyHandle); +RegError REGISTRY_CALLTYPE setValue(RegKeyHandle, rtl_uString*, RegValueType, RegValue, sal_uInt32); +RegError REGISTRY_CALLTYPE setLongListValue(RegKeyHandle, rtl_uString*, sal_Int32*, sal_uInt32); +RegError REGISTRY_CALLTYPE setStringListValue(RegKeyHandle, rtl_uString*, sal_Char**, sal_uInt32); +RegError REGISTRY_CALLTYPE setUnicodeListValue(RegKeyHandle, rtl_uString*, sal_Unicode**, sal_uInt32); +RegError REGISTRY_CALLTYPE getValueInfo(RegKeyHandle, rtl_uString*, RegValueType*, sal_uInt32*); +RegError REGISTRY_CALLTYPE getValue(RegKeyHandle, rtl_uString*, RegValue); +RegError REGISTRY_CALLTYPE getLongListValue(RegKeyHandle, rtl_uString*, sal_Int32**, sal_uInt32*); +RegError REGISTRY_CALLTYPE getStringListValue(RegKeyHandle, rtl_uString*, sal_Char***, sal_uInt32*); +RegError REGISTRY_CALLTYPE getUnicodeListValue(RegKeyHandle, rtl_uString*, sal_Unicode***, sal_uInt32*); +RegError REGISTRY_CALLTYPE freeValueList(RegValueType, RegValue, sal_uInt32); +RegError REGISTRY_CALLTYPE createLink(RegKeyHandle, rtl_uString*, rtl_uString*); +RegError REGISTRY_CALLTYPE deleteLink(RegKeyHandle, rtl_uString*); +RegError REGISTRY_CALLTYPE getKeyType(RegKeyHandle, rtl_uString*, RegKeyType*); +RegError REGISTRY_CALLTYPE getLinkTarget(RegKeyHandle, rtl_uString*, rtl_uString**); +RegError REGISTRY_CALLTYPE getResolvedKeyName(RegKeyHandle, rtl_uString*, sal_Bool, rtl_uString**); +RegError REGISTRY_CALLTYPE getKeyNames(RegKeyHandle, rtl_uString*, rtl_uString***, sal_uInt32*); +RegError REGISTRY_CALLTYPE freeKeyNames(rtl_uString**, sal_uInt32); + + +extern "C" Registry_Api* REGISTRY_CALLTYPE initRegistry_Api(void) +{ + static Registry_Api aApi= {&acquire, + &release, + &isReadOnly, + &openRootKey, + &getName, + &createRegistry, + &openRegistry, + &closeRegistry, + &destroyRegistry, + &loadKey, + &saveKey, + &mergeKey, + &dumpRegistry, + &acquireKey, + &releaseKey, + &isKeyReadOnly, + &getKeyName, + &createKey, + &openKey, + &openSubKeys, + &closeSubKeys, + &deleteKey, + &closeKey, + &setValue, + &setLongListValue, + &setStringListValue, + &setUnicodeListValue, + &getValueInfo, + &getValue, + &getLongListValue, + &getStringListValue, + &getUnicodeListValue, + &freeValueList, + &createLink, + &deleteLink, + &getKeyType, + &getLinkTarget, + &getResolvedKeyName, + &getKeyNames, + &freeKeyNames}; + + return (&aApi); +} + + +//********************************************************************* +// reg_loadRegKey +// +RegError REGISTRY_CALLTYPE reg_loadKey(RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName) +{ + ORegKey *pKey; + + if (hKey) + pKey = (ORegKey*)hKey; + else + return REG_INVALID_KEY; + + return loadKey(pKey->getRegistry(), hKey, keyName, regFileName); +} + +//********************************************************************* +// reg_saveKey +// +RegError REGISTRY_CALLTYPE reg_saveKey(RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName) +{ + ORegKey *pKey; + + if (hKey) + pKey = (ORegKey*)hKey; + else + return REG_INVALID_KEY; + + return saveKey(pKey->getRegistry(), hKey, keyName, regFileName); +} + +//********************************************************************* +// reg_mergeKey +// +RegError REGISTRY_CALLTYPE reg_mergeKey(RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName, + sal_Bool bWarnings, + sal_Bool bReport) +{ + ORegKey *pKey; + + if (hKey) + pKey = (ORegKey*)hKey; + else + return REG_INVALID_KEY; + + return mergeKey(pKey->getRegistry(), hKey, keyName, regFileName, bWarnings, bReport); +} + +//********************************************************************* +// reg_createRegistry +// +RegError REGISTRY_CALLTYPE reg_createRegistry(rtl_uString* registryName, + RegHandle* phRegistry) +{ + RegError ret; + + ORegistry* pReg = new ORegistry(); + if (ret = pReg->initRegistry(registryName, REG_CREATE)) + { + *phRegistry = NULL; + return ret; + } + + *phRegistry = pReg; + + return REG_NO_ERROR; +} + +//********************************************************************* +// reg_openRootKey +// +RegError REGISTRY_CALLTYPE reg_openRootKey(RegHandle hRegistry, + RegKeyHandle* phRootKey) +{ + return openRootKey(hRegistry, phRootKey); +} + + +//********************************************************************* +// reg_getName +// +const RegError REGISTRY_CALLTYPE reg_getName(RegHandle hRegistry, rtl_uString** pName) +{ + return getName(hRegistry, pName); +} + + +//********************************************************************* +// reg_isReadOnly +// +sal_Bool REGISTRY_CALLTYPE reg_isReadOnly(RegHandle hRegistry) +{ + return isReadOnly(hRegistry); +} + + +//********************************************************************* +// reg_openRegistry +// +RegError REGISTRY_CALLTYPE reg_openRegistry(rtl_uString* registryName, + RegHandle* phRegistry, + RegAccessMode accessMode) +{ + RegError _ret; + + ORegistry* pReg = new ORegistry(); + if (_ret = pReg->initRegistry(registryName, accessMode)) + { + *phRegistry = NULL; + return _ret; + } + + *phRegistry = pReg; + + return REG_NO_ERROR; +} + +//********************************************************************* +// reg_closeRegistry +// +RegError REGISTRY_CALLTYPE reg_closeRegistry(RegHandle hRegistry) +{ + ORegistry* pReg; + + if (hRegistry) + { + pReg = (ORegistry*)hRegistry; + delete(pReg); + return REG_NO_ERROR; + } else + { + return REG_REGISTRY_NOT_OPEN; + } +} + + +//********************************************************************* +// reg_destroyRegistry +// +RegError REGISTRY_CALLTYPE reg_destroyRegistry(RegHandle hRegistry, + rtl_uString* registryName) +{ + return destroyRegistry(hRegistry, registryName); +} + + +//********************************************************************* +// reg_dumpRegistry +// +RegError REGISTRY_CALLTYPE reg_dumpRegistry(RegKeyHandle hKey) +{ + ORegKey *pKey; + + if (hKey) + pKey = (ORegKey*)hKey; + else + return REG_INVALID_KEY; + + return dumpRegistry(pKey->getRegistry(), hKey); +} + + diff --git a/registry/source/regkey.cxx b/registry/source/regkey.cxx new file mode 100644 index 000000000000..7da6044705a2 --- /dev/null +++ b/registry/source/regkey.cxx @@ -0,0 +1,1298 @@ +/************************************************************************* + * + * $RCSfile: regkey.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _REGISTRY_REGISTRY_HXX_ +#include <registry/registry.hxx> +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + +#ifndef _REGIMPL_HXX_ +#include "regimpl.hxx" +#endif + +#ifndef _KEYIMPL_HXX_ +#include "keyimpl.hxx" +#endif + + +//********************************************************************* +// acquireKey +// +void REGISTRY_CALLTYPE acquireKey(RegKeyHandle hKey) +{ + ORegKey* pKey = (ORegKey*) hKey; + + if (pKey != NULL) + pKey->acquire(); +} + + +//********************************************************************* +// releaseKey +// +void REGISTRY_CALLTYPE releaseKey(RegKeyHandle hKey) +{ + ORegKey* pKey = (ORegKey*) hKey; + + if (pKey) + { + if (pKey->release() == 0) + delete pKey; + } +} + + +//********************************************************************* +// isKeyReadOnly +// +sal_Bool REGISTRY_CALLTYPE isKeyReadOnly(RegKeyHandle hKey) +{ + if (hKey) + { + return ((ORegKey*)hKey)->isReadOnly(); + } else + { + return sal_False; + } +} + + +//********************************************************************* +// getKeyName +// +RegError REGISTRY_CALLTYPE getKeyName(RegKeyHandle hKey, rtl_uString** pKeyName) +{ + if (hKey) + { + rtl_uString_assign( pKeyName, ((ORegKey*)hKey)->getName().pData ); + return REG_NO_ERROR; + } else + { + rtl_uString_new(pKeyName); + return REG_INVALID_KEY; + } +} + + +//********************************************************************* +// createKey +// +RegError REGISTRY_CALLTYPE createKey(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle* phNewKey) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + { + phNewKey = NULL; + return REG_INVALID_KEY; + } + } else + { + phNewKey = NULL; + return REG_INVALID_KEY; + } + + if (pKey->isReadOnly()) + return REG_REGISTRY_READONLY; + + return pKey->createKey(keyName, phNewKey); +} + +//********************************************************************* +// openKey +// +RegError REGISTRY_CALLTYPE openKey(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle* phOpenKey) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + { + phOpenKey = NULL; + return REG_INVALID_KEY; + } + } else + { + phOpenKey = NULL; + return REG_INVALID_KEY; + } + + return pKey->openKey(keyName, phOpenKey); +} + +//********************************************************************* +// openSubKeys +// +RegError REGISTRY_CALLTYPE openSubKeys(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle** pphSubKeys, + sal_uInt32* pnSubKeys) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + { + pphSubKeys = NULL; + return REG_INVALID_KEY; + } + } else + { + pphSubKeys = NULL; + return REG_INVALID_KEY; + } + + return pKey->openSubKeys(keyName, pphSubKeys, pnSubKeys); +} + +//********************************************************************* +// closeSubKeys +// +RegError REGISTRY_CALLTYPE closeSubKeys(RegKeyHandle* phSubKeys, + sal_uInt32 nSubKeys) +{ + RegError _ret = REG_NO_ERROR; + + if (phSubKeys) + { + ORegistry* pReg = NULL; + + pReg = ((ORegKey*)phSubKeys[0])->getRegistry(); + + for (int i=0; (i < nSubKeys) && (_ret == REG_NO_ERROR); i++) + { + _ret = pReg->closeKey(phSubKeys[i]); + } + + rtl_freeMemory(phSubKeys); + } + else + _ret = REG_INVALID_KEY; + + return _ret; +} + + +//********************************************************************* +// deleteKey +// +RegError REGISTRY_CALLTYPE deleteKey(RegKeyHandle hKey, + rtl_uString* keyName) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + if (pKey->isReadOnly()) + return REG_REGISTRY_READONLY; + + return pKey->deleteKey(keyName); +} + +//********************************************************************* +// closeKey +// +RegError REGISTRY_CALLTYPE closeKey(RegKeyHandle hKey) +{ + ORegKey* pKey; + ORegistry* pReg; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + pReg = pKey->getRegistry(); + + if (pReg->closeKey(hKey)) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + return REG_NO_ERROR; +} + + +//********************************************************************* +// setValue +// +RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, + rtl_uString* keyName, + RegValueType valueType, + RegValue pData, + sal_uInt32 valueSize) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + if (pKey->isReadOnly()) + return REG_REGISTRY_READONLY; + + OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value") ); + if (keyName->length) + { + RegKeyHandle hSubKey; + ORegKey* pSubKey; + RegError _ret1, _ret2; + if (_ret1 = pKey->openKey(keyName, &hSubKey)) + return _ret1; + + pSubKey = (ORegKey*)hSubKey; + if (_ret1 = pSubKey->setValue(valueName, valueType, pData, valueSize)) + { + if (_ret2 = pKey->closeKey(hSubKey)) + return _ret2; + else + return _ret1; + } + + return pKey->closeKey(hSubKey); + } + + return pKey->setValue(valueName, valueType, pData, valueSize); +} + +//********************************************************************* +// setLongValueList +// +RegError REGISTRY_CALLTYPE setLongListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Int32* pValueList, + sal_uInt32 len) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + if (pKey->isReadOnly()) + return REG_REGISTRY_READONLY; + + OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value") ); + if (keyName->length) + { + RegKeyHandle hSubKey; + ORegKey* pSubKey; + RegError _ret1, _ret2; + if (_ret1 = pKey->openKey(keyName, &hSubKey)) + return _ret1; + + pSubKey = (ORegKey*)hSubKey; + if (_ret1 = pSubKey->setLongListValue(valueName, pValueList, len)) + { + if (_ret2 = pKey->closeKey(hSubKey)) + return _ret2; + else + return _ret1; + } + + return pKey->closeKey(hSubKey); + } + + return pKey->setLongListValue(valueName, pValueList, len); +} + +//********************************************************************* +// setStringValueList +// +RegError REGISTRY_CALLTYPE setStringListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Char** pValueList, + sal_uInt32 len) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + if (pKey->isReadOnly()) + return REG_REGISTRY_READONLY; + + OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value") ); + if (keyName->length) + { + RegKeyHandle hSubKey; + ORegKey* pSubKey; + RegError _ret1, _ret2; + if (_ret1 = pKey->openKey(keyName, &hSubKey)) + return _ret1; + + pSubKey = (ORegKey*)hSubKey; + if (_ret1 = pSubKey->setStringListValue(valueName, pValueList, len)) + { + if (_ret2 = pKey->closeKey(hSubKey)) + return _ret2; + else + return _ret1; + } + + return pKey->closeKey(hSubKey); + } + + return pKey->setStringListValue(valueName, pValueList, len); +} + +//********************************************************************* +// setUnicodeValueList +// +RegError REGISTRY_CALLTYPE setUnicodeListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Unicode** pValueList, + sal_uInt32 len) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + if (pKey->isReadOnly()) + return REG_REGISTRY_READONLY; + + OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value") ); + if (keyName->length) + { + RegKeyHandle hSubKey; + ORegKey* pSubKey; + RegError _ret1, _ret2; + if (_ret1 = pKey->openKey(keyName, &hSubKey)) + return _ret1; + + pSubKey = (ORegKey*)hSubKey; + if (_ret1 = pSubKey->setUnicodeListValue(valueName, pValueList, len)) + { + if (_ret2 = pKey->closeKey(hSubKey)) + return _ret2; + else + return _ret1; + } + + return pKey->closeKey(hSubKey); + } + + return pKey->setUnicodeListValue(valueName, pValueList, len); +} + +//********************************************************************* +// getValueInfo +// +RegError REGISTRY_CALLTYPE getValueInfo(RegKeyHandle hKey, + rtl_uString* keyName, + RegValueType* pValueType, + sal_uInt32* pValueSize) +{ + ORegKey* pKey; + RegValueType valueType; + sal_uInt32 valueSize; + + *pValueType = RG_VALUETYPE_NOT_DEFINED; + *pValueSize = 0; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value") ); + if (keyName->length) + { + RegKeyHandle hSubKey; + ORegKey* pSubKey; + RegError _ret; + if (_ret = pKey->openKey(keyName, &hSubKey)) + return _ret; + + pSubKey = (ORegKey*)hSubKey; + if (pSubKey->getValueInfo(valueName, &valueType, &valueSize)) + { + if (_ret = pKey->closeKey(hSubKey)) + return _ret; + else + return REG_INVALID_VALUE; + } + + *pValueType = valueType; + *pValueSize = valueSize; + + return pKey->closeKey(hSubKey); + } + + + if (pKey->getValueInfo(valueName, &valueType, &valueSize)) + { + return REG_INVALID_VALUE; + } + + *pValueType = valueType; + *pValueSize = valueSize; + + return REG_NO_ERROR; +} + +//********************************************************************* +// getValueInfo +// +RegError REGISTRY_CALLTYPE getValue(RegKeyHandle hKey, + rtl_uString* keyName, + RegValue pValue) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + { + pValue = NULL; + return REG_INVALID_KEY; + } + } else + { + pValue = NULL; + return REG_INVALID_KEY; + } + + OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value") ); + if (keyName->length) + { + RegKeyHandle hSubKey; + ORegKey* pSubKey; + RegError _ret1, _ret2; + if (_ret1 = pKey->openKey(keyName, &hSubKey)) + { + pValue = NULL; + return _ret1; + } + + pSubKey = (ORegKey*)hSubKey; + if (_ret1 = pSubKey->getValue(valueName, pValue)) + { + if (_ret2 = pKey->closeKey(hSubKey)) + { + pValue = NULL; + return _ret2; + } else + { + pValue = NULL; + return _ret1; + } + } + + return pKey->closeKey(hSubKey); + } + + return pKey->getValue(valueName, pValue); +} + +//********************************************************************* +// getLongValueList +// +RegError REGISTRY_CALLTYPE getLongListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Int32** pValueList, + sal_uInt32* pLen) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + { + pValueList = NULL; + *pLen = 0; + return REG_INVALID_KEY; + } + } else + { + pValueList = NULL; + *pLen = 0; + return REG_INVALID_KEY; + } + + OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value") ); + if (keyName->length) + { + RegKeyHandle hSubKey; + ORegKey* pSubKey; + RegError _ret1, _ret2; + if (_ret1 = pKey->openKey(keyName, &hSubKey)) + { + pValueList = NULL; + *pLen = 0; + return _ret1; + } + + pSubKey = (ORegKey*)hSubKey; + + if (_ret1 = pSubKey->getLongListValue(valueName, pValueList, pLen)) + { + if (_ret2 = pKey->closeKey(hSubKey)) + { + pValueList = NULL; + *pLen = 0; + return _ret2; + } else + { + pValueList = NULL; + *pLen = 0; + return _ret1; + } + } + + return pKey->closeKey(hSubKey); + } + + return pKey->getLongListValue(valueName, pValueList, pLen); +} + +//********************************************************************* +// getStringValueList +// +RegError REGISTRY_CALLTYPE getStringListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Char*** pValueList, + sal_uInt32* pLen) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + { + pValueList = NULL; + *pLen = 0; + return REG_INVALID_KEY; + } + } else + { + pValueList = NULL; + *pLen = 0; + return REG_INVALID_KEY; + } + + OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value") ); + if (keyName->length) + { + RegKeyHandle hSubKey; + ORegKey* pSubKey; + RegError _ret1, _ret2; + if ((_ret1 = pKey->openKey(keyName, &hSubKey))) + { + pValueList = NULL; + *pLen = 0; + return _ret1; + } + + pSubKey = (ORegKey*)hSubKey; + + if (_ret1 = pSubKey->getStringListValue(valueName, pValueList, pLen)) + { + if (_ret2 = pKey->closeKey(hSubKey)) + { + pValueList = NULL; + *pLen = 0; + return _ret2; + } else + { + pValueList = NULL; + *pLen = 0; + return _ret1; + } + } + + return pKey->closeKey(hSubKey); + } + + return pKey->getStringListValue(valueName, pValueList, pLen); +} + +//********************************************************************* +// getUnicodeListValue +// +RegError REGISTRY_CALLTYPE getUnicodeListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Unicode*** pValueList, + sal_uInt32* pLen) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + { + pValueList = NULL; + *pLen = 0; + return REG_INVALID_KEY; + } + } else + { + pValueList = NULL; + *pLen = 0; + return REG_INVALID_KEY; + } + + OUString valueName( RTL_CONSTASCII_USTRINGPARAM("value") ); + if (keyName->length) + { + RegKeyHandle hSubKey; + ORegKey* pSubKey; + RegError _ret1, _ret2; + if (_ret1 = pKey->openKey(keyName, &hSubKey)) + { + pValueList = NULL; + *pLen = 0; + return _ret1; + } + + pSubKey = (ORegKey*)hSubKey; + + if (_ret1 = pSubKey->getUnicodeListValue(valueName, pValueList, pLen)) + { + if (_ret2 = pKey->closeKey(hSubKey)) + { + pValueList = NULL; + *pLen = 0; + return _ret2; + } else + { + pValueList = NULL; + *pLen = 0; + return _ret1; + } + } + + return pKey->closeKey(hSubKey); + } + + return pKey->getUnicodeListValue(valueName, pValueList, pLen); +} + +//********************************************************************* +// freeValueList +// +RegError REGISTRY_CALLTYPE freeValueList(RegValueType valueType, + RegValue pValueList, + sal_uInt32 len) +{ + switch (valueType) + { + case 5: + { + sal_Int32* pVList = (sal_Int32*)pValueList; + rtl_freeMemory(pValueList); + } + break; + case 6: + { + sal_Char** pVList = (sal_Char**)pValueList; + for (int i=0; i < len; i++) + { + rtl_freeMemory(pVList[i]); + } + + rtl_freeMemory(pVList); + } + break; + case 7: + { + sal_Unicode** pVList = (sal_Unicode**)pValueList; + for (int i=0; i < len; i++) + { + rtl_freeMemory(pVList[i]); + } + + rtl_freeMemory(pVList); + } + break; + default: + return REG_INVALID_VALUE; + } + + pValueList = NULL; + return REG_NO_ERROR; +} + + +//********************************************************************* +// createLink +// +RegError REGISTRY_CALLTYPE createLink(RegKeyHandle hKey, + rtl_uString* linkName, + rtl_uString* linkTarget) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + if (pKey->isReadOnly()) + return REG_REGISTRY_READONLY; + + return pKey->createLink(linkName, linkTarget); +} + +//********************************************************************* +// deleteLink +// +RegError REGISTRY_CALLTYPE deleteLink(RegKeyHandle hKey, + rtl_uString* linkName) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + if (pKey->isReadOnly()) + return REG_REGISTRY_READONLY; + + return pKey->deleteLink(linkName); +} + +//********************************************************************* +// getKeyType +// +RegError REGISTRY_CALLTYPE getKeyType(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyType* pKeyType) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + return pKey->getKeyType(keyName, pKeyType); +} + +//********************************************************************* +// getLinkTarget +// +RegError REGISTRY_CALLTYPE getLinkTarget(RegKeyHandle hKey, + rtl_uString* linkName, + rtl_uString** pLinkTarget) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + OUString linkTarget; + RegError ret = pKey->getLinkTarget(linkName, linkTarget); + if (!ret) + rtl_uString_assign(pLinkTarget, linkTarget.pData); + return ret; +} + + +//********************************************************************* +// getName +// +RegError REGISTRY_CALLTYPE getResolvedKeyName(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Bool firstLinkOnly, + rtl_uString** pResolvedName) +{ + ORegKey *pKey; + RegError _ret = REG_NO_ERROR; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + OUString resolvedName; + _ret = pKey->getResolvedKeyName(keyName, resolvedName, firstLinkOnly); + if (!_ret) + rtl_uString_assign(pResolvedName, resolvedName.pData); + return _ret; +} + + +//********************************************************************* +// getKeyNames +// +RegError REGISTRY_CALLTYPE getKeyNames(RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString*** pSubKeyNames, + sal_uInt32* pnSubKeys) +{ + ORegKey* pKey; + + if (hKey) + { + pKey = (ORegKey*)hKey; + + if (pKey->isDeleted()) + return REG_INVALID_KEY; + } else + return REG_INVALID_KEY; + + return pKey->getKeyNames(keyName, pSubKeyNames, pnSubKeys); +} + +//********************************************************************* +// freeKeyNames +// +RegError REGISTRY_CALLTYPE freeKeyNames(rtl_uString** pKeyNames, + sal_uInt32 nKeys) +{ + for (int i=0; i <nKeys; i++) + { + rtl_uString_release(pKeyNames[i]); + } + + rtl_freeMemory(pKeyNames); + + return REG_NO_ERROR; +} + +//********************************************************************* +// C API +// + +//********************************************************************* +// reg_createKey +// +RegError REGISTRY_CALLTYPE reg_createKey(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle* phNewKey) +{ + if (!hKey) + return REG_INVALID_KEY; + + return createKey(hKey, keyName, phNewKey); +} + +//********************************************************************* +// reg_openKey +// +RegError REGISTRY_CALLTYPE reg_openKey(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle* phOpenKey) +{ + if (!hKey) + return REG_INVALID_KEY; + + return openKey(hKey, keyName, phOpenKey); +} + +//********************************************************************* +// reg_openSubKeys +// +RegError REGISTRY_CALLTYPE reg_openSubKeys(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle** pphSubKeys, + sal_uInt32* pnSubKeys) +{ + if (!hKey) + return REG_INVALID_KEY; + + return openSubKeys(hKey, keyName, pphSubKeys, pnSubKeys); +} + +//********************************************************************* +// reg_closeSubKeys +// +RegError REGISTRY_CALLTYPE reg_closeSubKeys(RegKeyHandle* pphSubKeys, + sal_uInt32 nSubKeys) +{ + if (!pphSubKeys) + return REG_INVALID_KEY; + + return closeSubKeys(pphSubKeys, nSubKeys); +} + +//********************************************************************* +// reg_deleteKey +// +RegError REGISTRY_CALLTYPE reg_deleteKey(RegKeyHandle hKey, + rtl_uString* keyName) +{ + if (!hKey) + return REG_INVALID_KEY; + + return deleteKey(hKey, keyName); +} + +//********************************************************************* +// reg_closeKey +// +RegError REGISTRY_CALLTYPE reg_closeKey(RegKeyHandle hKey) +{ + if (!hKey) + return REG_INVALID_KEY; + + return closeKey(hKey); +} + + +//********************************************************************* +// reg_getKeyName +// +const RegError REGISTRY_CALLTYPE reg_getKeyName(RegKeyHandle hKey, rtl_uString** pKeyName) +{ + if (hKey) + { + rtl_uString_assign( pKeyName, ((ORegKey*)hKey)->getName().pData ); + return REG_NO_ERROR; + } else + { + rtl_uString_new( pKeyName ); + return REG_INVALID_KEY; + } +} + +//********************************************************************* +// reg_setValue +// +RegError REGISTRY_CALLTYPE reg_setValue(RegKeyHandle hKey, + rtl_uString* keyName, + RegValueType valueType, + RegValue pData, + sal_uInt32 valueSize) +{ + if (!hKey) + return REG_INVALID_KEY; + + return setValue(hKey, keyName, valueType, pData, valueSize); +} + +//********************************************************************* +// reg_setLongListValue +// +RegError REGISTRY_CALLTYPE reg_setLongListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Int32* pValueList, + sal_uInt32 len) +{ + if (!hKey) + return REG_INVALID_KEY; + + return setLongListValue(hKey, keyName, pValueList, len); +} + +//********************************************************************* +// reg_setStringListValue +// +RegError REGISTRY_CALLTYPE reg_setStringListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Char** pValueList, + sal_uInt32 len) +{ + if (!hKey) + return REG_INVALID_KEY; + + return setStringListValue(hKey, keyName, pValueList, len); +} + +//********************************************************************* +// reg_setUnicodeListValue +// +RegError REGISTRY_CALLTYPE reg_setUnicodeListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Unicode** pValueList, + sal_uInt32 len) +{ + if (!hKey) + return REG_INVALID_KEY; + + return setUnicodeListValue(hKey, keyName, pValueList, len); +} + +//********************************************************************* +// reg_getValueInfo +// +RegError REGISTRY_CALLTYPE reg_getValueInfo(RegKeyHandle hKey, + rtl_uString* keyName, + RegValueType* pValueType, + sal_uInt32* pValueSize) +{ + if (!hKey) + return REG_INVALID_KEY; + + return getValueInfo(hKey, keyName, pValueType, pValueSize); +} + +//********************************************************************* +// reg_getValueInfo +// +RegError REGISTRY_CALLTYPE reg_getValue(RegKeyHandle hKey, + rtl_uString* keyName, + RegValue pData) +{ + if (!hKey) + return REG_INVALID_KEY; + + return getValue(hKey, keyName, pData); +} + +//********************************************************************* +// reg_getLongListValue +// +RegError REGISTRY_CALLTYPE reg_getLongListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Int32** pValueList, + sal_uInt32* pLen) +{ + if (!hKey) + return REG_INVALID_KEY; + + return getLongListValue(hKey, keyName, pValueList, pLen); +} + +//********************************************************************* +// reg_getStringListValue +// +RegError REGISTRY_CALLTYPE reg_getStringListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Char*** pValueList, + sal_uInt32* pLen) +{ + if (!hKey) + return REG_INVALID_KEY; + + return getStringListValue(hKey, keyName, pValueList, pLen); +} + +//********************************************************************* +// reg_getUnicodeListValue +// +RegError REGISTRY_CALLTYPE reg_getUnicodeListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Unicode*** pValueList, + sal_uInt32* pLen) +{ + if (!hKey) + return REG_INVALID_KEY; + + return getUnicodeListValue(hKey, keyName, pValueList, pLen); +} + +//********************************************************************* +// reg_freeValueList +// +RegError REGISTRY_CALLTYPE reg_freeValueList(RegValueType valueType, + RegValue pValueList, + sal_uInt32 len) +{ + if (pValueList) + return freeValueList(valueType, pValueList, len); + else + return REG_INVALID_VALUE; +} + +//********************************************************************* +// reg_createLink +// +RegError REGISTRY_CALLTYPE reg_createLink(RegKeyHandle hKey, + rtl_uString* linkName, + rtl_uString* linkTarget) +{ + if (!hKey) + return REG_INVALID_KEY; + + return createLink(hKey, linkName, linkTarget); +} + +//********************************************************************* +// reg_deleteLink +// +RegError REGISTRY_CALLTYPE reg_deleteLink(RegKeyHandle hKey, + rtl_uString* linkName) +{ + if (!hKey) + return REG_INVALID_KEY; + + return deleteLink(hKey, linkName); +} + +//********************************************************************* +// reg_getKeyType +// +RegError REGISTRY_CALLTYPE reg_getKeyType(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyType* pKeyType) +{ + if (!hKey) + return REG_INVALID_KEY; + + return getKeyType(hKey, keyName, pKeyType); +} + +//********************************************************************* +// reg_getLinkTarget +// +RegError REGISTRY_CALLTYPE reg_getLinkTarget(RegKeyHandle hKey, + rtl_uString* linkName, + rtl_uString** pLinkTarget) +{ + if (!hKey) + return REG_INVALID_KEY; + + return getLinkTarget(hKey, linkName, pLinkTarget); +} + + +//********************************************************************* +// reg_getResolvedKeyName +// +RegError REGISTRY_CALLTYPE reg_getResolvedKeyName(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Bool firstLinkOnly, + rtl_uString** pResolvedName) +{ + ORegKey *pKey; + + if (hKey) + pKey = (ORegKey*)hKey; + else + return REG_INVALID_KEY; + + return getResolvedKeyName(hKey, keyName, firstLinkOnly, pResolvedName); +} + + diff --git a/registry/source/regmap.hxx b/registry/source/regmap.hxx new file mode 100644 index 000000000000..1bf07bb3a69a --- /dev/null +++ b/registry/source/regmap.hxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * $RCSfile: regmap.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _REGMAP_HXX_ +#define _REGMAP_HXX_ + +#if STLPORT_VERSION<321 +#include <hash_map.h> +#include <list.h> +#include <set.h> +#else +#include <hash_map> +#include <list> +#include <set> +#endif + +#ifndef _VOS_MACROS_HXX_ +#include <vos/macros.hxx> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +using namespace rtl; + +class ORegKey; + +struct EqualString +{ + bool operator()(const OUString& str1, const OUString& str2) const + { + return (str1 == str2); + } +}; + +struct HashString +{ + size_t operator()(const OUString& str) const + { + return str.hashCode(); + } +}; + +struct LessString +{ + bool operator()(const OUString& str1, const OUString& str2) const + { + return (str1 < str2); + } +}; + +typedef NAMESPACE_STD(hash_map) <OUString, ORegKey*, HashString, EqualString> KeyMap; + +typedef NAMESPACE_STD(list) <ORegKey*> LinkList; + +typedef NAMESPACE_STD(set) <OUString, LessString> StringSet; + +#endif diff --git a/registry/test/makefile.mk b/registry/test/makefile.mk new file mode 100644 index 000000000000..c3dddd2b3a54 --- /dev/null +++ b/registry/test/makefile.mk @@ -0,0 +1,133 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=.. + +PRJNAME=registry +TARGET=regtest + +USE_LDUMP2=TRUE +#LDUMP2=LDUMP3 + + +# --- Settings ----------------------------------------------------- +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + + +# ------------------------------------------------------------------ +CDEFS += -DDLL_VERSION=\"$(UPD)$(DLLPOSTFIX)\" + +CXXFILES= \ + testregcpp.cxx \ + testmerge.cxx + + +LIB1TARGET= $(SLB)$/$(TARGET).lib + +LIB1OBJFILES= \ + $(SLO)$/testregcpp.obj \ + $(SLO)$/testmerge.obj + + +SHL1TARGET= rgt$(UPD)$(DLLPOSTFIX) +SHL1IMPLIB= rgt +SHL1STDLIBS= \ + $(SALLIB) \ + $(VOSLIB) \ + $(STDLIBCPP) + +.IF "$(GUI)" == "WNT" +SHL1STDLIBS += \ + $(LIBCMT) \ + $(LIBCIMT) +.ENDIF + + +SHL1LIBS= $(LIB1TARGET) +SHL1DEPN= $(LIB1TARGET) +SHL1DEF= $(MISC)$/$(SHL1TARGET).def +DEF1NAME= $(SHL1TARGET) + +DEF1DEPN =$(MISC)$/rgt$(UPD)$(DLLPOSTFIX).flt $(SLOFILES) +DEFLIB1NAME =$(TARGET) +DEF1DES =Registry Runtime - TestDll + +# --- Targets ------------------------------------------------------ + +#all: \ +# ALLTAR + +.INCLUDE : target.mk + +# --- SO2-Filter-Datei --- + + +$(MISC)$/rgt$(UPD)$(DLLPOSTFIX).flt: + @echo ------------------------------ + @echo Making: $@ + @echo WEP>$@ + @echo LIBMAIN>>$@ + @echo LibMain>>$@ + + diff --git a/registry/test/testmerge.cxx b/registry/test/testmerge.cxx new file mode 100644 index 000000000000..f277535890e0 --- /dev/null +++ b/registry/test/testmerge.cxx @@ -0,0 +1,492 @@ +/************************************************************************* + * + * $RCSfile: testmerge.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <iostream.h> +#include <stdio.h> +#include <string.h> + +#include "registry/registry.hxx" +#include "registry/reflread.hxx" +#include "registry/reflwrit.hxx" + +#ifndef _VOS_MODULE_HXX +#include <vos/module.hxx> +#endif + +#ifndef _VOS_DIAGNOSE_HXX +#include <vos/diagnose.hxx> +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + + +using namespace rtl; + +sal_Int32 lValue1 = 123456789; +sal_Int32 lValue2 = 54321; +sal_Int32 lValue3 = 111333111; +sal_Int32 lValue4 = 333111333; +sal_Char* sValue = "string Value"; +OUString wValue = rtl::OUString::createFromAscii( "unicode Value" ); + + +void test_generateMerge1() +{ + RegistryLoader* pLoader = new RegistryLoader(); + + if (!pLoader->isLoaded()) + { + delete pLoader; + return; + } + + Registry *myRegistry = new Registry(*pLoader); + delete pLoader; + + RegistryKey rootKey, key1, key2, key3, key4, key5, key6, key7, key8, key9; + + VOS_ENSHURE(!myRegistry->create(OUString::createFromAscii("merge1.rdb")), "testGenerateMerge1 error 1"); + VOS_ENSHURE(!myRegistry->openRootKey(rootKey), "testGenerateMerge1 error 2"); + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("MergeKey1"), key1), "testGenerateMerge1 error 3"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1/MK1SubKey1"), key2), "testGenerateMerge1 error 4"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1/MK1SubKey1/KeyWithLongValue"), key3), "testGenerateMerge1 error 5"); + VOS_ENSHURE(!key3.setValue(OUString(), RG_VALUETYPE_LONG, &lValue1, sizeof(sal_Int32)), "testGenerateMerge1 error 5a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1/MK1SubKey2"), key4), "testGenerateMerge1 error 6"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1/MK1SubKey2/KeyWithStringValue"), key5), "testGenerateMerge1 error 7"); + VOS_ENSHURE(!key5.setValue(OUString(), RG_VALUETYPE_STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 7a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1/MK1SubKey3"), key6), "testGenerateMerge1 error 8"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), key7), "testGenerateMerge1 error 9"); + VOS_ENSHURE(!key7.setValue(OUString(), RG_VALUETYPE_UNICODE, (void*)wValue.getStr(), ((wValue.getLength()+1)*sizeof(sal_Unicode))), "testGenerateMerge1 error 9a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1/MK1SubKey4"), key8), "testGenerateMerge1 error 10"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), key9), "testGenerateMerge1 error 11"); + VOS_ENSHURE(!key9.setValue(OUString(), RG_VALUETYPE_BINARY, "abcdefghijklmnopqrstuvwxyz", 27), "testGenerateMerge1 error 11a"); + + + VOS_ENSHURE(!key1.closeKey() && + !key2.closeKey() && + !key3.closeKey() && + !key4.closeKey() && + !key5.closeKey() && + !key6.closeKey() && + !key7.closeKey() && + !key8.closeKey() && + !key9.closeKey(), "testGenerateMerge1 error 12"); + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("MergeKey1u2"), key1), "testGenerateMerge1 error 13"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey11"), key2), "testGenerateMerge1 error 14"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), key3), "testGenerateMerge1 error 15"); + VOS_ENSHURE(!key3.setValue(OUString(), RG_VALUETYPE_LONG, &lValue2, sizeof(sal_Int32)), "testGenerateMerge1 error 15a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey12"), key4), "testGenerateMerge1 error 16"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), key5), "testGenerateMerge1 error 17"); + VOS_ENSHURE(!key5.setValue(OUString(), RG_VALUETYPE_STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 17a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey13"), key6), "testGenerateMerge1 error 18"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), key7), "testGenerateMerge1 error 19"); + VOS_ENSHURE(!key7.setValue(OUString(), RG_VALUETYPE_UNICODE, (void*)wValue.getStr(), ((wValue.getLength()+1)*sizeof(sal_Unicode))), "testGenerateMerge1 error 19a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK12SubKey1u2"), key8), "testGenerateMerge1 error 20"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), key9), "testGenerateMerge1 error 21"); + VOS_ENSHURE(!key9.setValue(OUString(), RG_VALUETYPE_LONG, &lValue3, sizeof(sal_Int32)), "testGenerateMerge1 error 21a"); + + VOS_ENSHURE(!rootKey.closeKey() && + !key1.closeKey() && + !key2.closeKey() && + !key3.closeKey() && + !key4.closeKey() && + !key5.closeKey() && + !key6.closeKey() && + !key7.closeKey() && + !key8.closeKey() && + !key9.closeKey(), "testGenerateMerge1 error 22"); + + + delete myRegistry; + + cout << "test_generateMerge1() Ok!\n"; + return; +} + +void test_generateMerge2() +{ + RegistryLoader* pLoader = new RegistryLoader(); + + if (!pLoader->isLoaded()) + { + delete pLoader; + return; + } + + Registry *myRegistry = new Registry(*pLoader); + delete pLoader; + + RegistryKey rootKey, key1, key2, key3, key4, key5, key6, key7, key8, key9; + + VOS_ENSHURE(!myRegistry->create(OUString::createFromAscii("merge2.rdb")), "testGenerateMerge2 error 1"); + VOS_ENSHURE(!myRegistry->openRootKey(rootKey), "testGenerateMerge2 error 2"); + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("MergeKey2"), key1), "testGenerateMerge2 error 3"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey2/MK2SubKey1"), key2), "testGenerateMerge2 error 4"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), key3), "testGenerateMerge2 error 5"); + VOS_ENSHURE(!key3.setValue(OUString(), RG_VALUETYPE_BINARY, "1234567890", 11), "testGenerateMerge1 error 5a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey2/MK2SubKey2"), key4), "testGenerateMerge2 error 6"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), key5), "testGenerateMerge2 error 7"); + VOS_ENSHURE(!key5.setValue(OUString(), RG_VALUETYPE_UNICODE, (void*)wValue.getStr(), ((wValue.getLength()+1)*sizeof(sal_Unicode))), "testGenerateMerge1 error 7a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey2/MK2SubKey3"), key6), "testGenerateMerge2 error 8"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey2/MK2SubKey3/KeyWithStringValue"), key7), "testGenerateMerge2 error 9"); + VOS_ENSHURE(!key7.setValue(OUString(), RG_VALUETYPE_STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 9a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey2/MK2SubKey4"), key8), "testGenerateMerge2 error 10"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey2/MK2SubKey4/KeyWithLongValue"), key9), "testGenerateMerge2 error 11"); + VOS_ENSHURE(!key9.setValue(OUString(), RG_VALUETYPE_LONG, &lValue1, sizeof(sal_Int32)), "testGenerateMerge1 error 11a"); + + VOS_ENSHURE(!key1.closeKey() && + !key2.closeKey() && + !key3.closeKey() && + !key4.closeKey() && + !key5.closeKey() && + !key6.closeKey() && + !key7.closeKey() && + !key8.closeKey() && + !key9.closeKey(), "testGenerateMerge2 error 12"); + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("MergeKey1u2"), key1), "testGenerateMerge2 error 13"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey21"), key2), "testGenerateMerge2 error 14"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), key3), "testGenerateMerge2 error 15"); + VOS_ENSHURE(!key3.setValue(OUString(), RG_VALUETYPE_BINARY, "a1b2c3d4e5f6g7h8i9", 19), "testGenerateMerge1 error 15a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey22"), key4), "testGenerateMerge2 error 16"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), key5), "testGenerateMerge2 error 17"); + VOS_ENSHURE(!key5.setValue(OUString(), RG_VALUETYPE_LONG, &lValue2, sizeof(sal_Int32)), "testGenerateMerge1 error 17a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey23"), key6), "testGenerateMerge2 error 18"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), key7), "testGenerateMerge2 error 19"); + VOS_ENSHURE(!key7.setValue(OUString(), RG_VALUETYPE_STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 19a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK12SubKey1u2"), key8), "testGenerateMerge2 error 20"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), key9), "testGenerateMerge2 error 21"); + VOS_ENSHURE(!key9.setValue(OUString(), RG_VALUETYPE_LONG, &lValue4, sizeof(sal_Int32)), "testGenerateMerge1 error 21a"); + + VOS_ENSHURE(!rootKey.closeKey() && + !key1.closeKey() && + !key2.closeKey() && + !key3.closeKey() && + !key4.closeKey() && + !key5.closeKey() && + !key6.closeKey() && + !key7.closeKey() && + !key8.closeKey() && + !key9.closeKey(), "testGenerateMerge2 error 22"); + + + delete myRegistry; + + cout << "test_generateMerge2() Ok!\n"; + return; +} + +void test_merge() +{ + RegistryLoader* pLoader = new RegistryLoader(); + + if (!pLoader->isLoaded()) + { + delete pLoader; + return; + } + + Registry *myRegistry = new Registry(*pLoader); + delete pLoader; + + RegistryKey rootKey, key1, mkey1, key2, mkey2, key1u2, mkey1u2; + + VOS_ENSHURE(!myRegistry->create(OUString::createFromAscii("mergetest.rdb")), "testMerge error 1"); + VOS_ENSHURE(myRegistry->getName().equals(OUString::createFromAscii("mergetest.rdb")), "testMerge error 1.a)"); + VOS_ENSHURE(!myRegistry->openRootKey(rootKey), "testMerge error 2"); + VOS_ENSHURE(!myRegistry->loadKey(rootKey, OUString::createFromAscii("/stardiv/IchbineinMergeKey"), + OUString::createFromAscii("merge1.rdb")), "testMerge error 3"); + VOS_ENSHURE(!myRegistry->mergeKey(rootKey, OUString::createFromAscii("/stardiv/IchbineinMergeKey"), + OUString::createFromAscii("merge2.rdb")), "testMerge error 4"); + + /////////////////////////////////////////////////////////////////////////// + + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/stardiv/IchbineinMergeKey"), key1), "testMerge error 5"); + + VOS_ENSHURE(!key1.openKey(OUString::createFromAscii("MergeKey1"), mkey1), "testMerge error 6"); + VOS_ENSHURE(!mkey1.closeKey(), "testMerge error 7"); + + VOS_ENSHURE(!key1.openKey(OUString::createFromAscii("/MergeKey1/MK1SubKey1"), mkey1), "testMerge error 8"); + VOS_ENSHURE(!mkey1.closeKey(), "testMerge error 9"); + VOS_ENSHURE(!key1.openKey(OUString::createFromAscii("/MergeKey1/MK1SubKey1/KeyWithLongValue"), mkey1), "testMerge error 10"); + VOS_ENSHURE(!mkey1.closeKey(), "testMerge error 11"); + + VOS_ENSHURE(!key1.openKey(OUString::createFromAscii("/MergeKey1/MK1SubKey2"), mkey1), "testMerge error 12"); + VOS_ENSHURE(!mkey1.closeKey(), "testMerge error 13"); + VOS_ENSHURE(!key1.openKey(OUString::createFromAscii("/MergeKey1/MK1SubKey2/KeyWithStringValue"), mkey1), "testMerge error 14"); + VOS_ENSHURE(!mkey1.closeKey(), "testMerge error 15"); + + VOS_ENSHURE(!key1.openKey(OUString::createFromAscii("/MergeKey1/MK1SubKey3"), mkey1), "testMerge error 16"); + VOS_ENSHURE(!mkey1.closeKey(), "testMerge error 17"); + VOS_ENSHURE(!key1.openKey(OUString::createFromAscii("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), mkey1), "testMerge error 18"); + VOS_ENSHURE(!mkey1.closeKey(), "testMerge error 19"); + + VOS_ENSHURE(!key1.openKey(OUString::createFromAscii("/MergeKey1/MK1SubKey4"), mkey1), "testMerge error 20"); + VOS_ENSHURE(!mkey1.closeKey(), "testMerge error 21"); + VOS_ENSHURE(!key1.openKey(OUString::createFromAscii("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), mkey1), "testMerge error 22"); + VOS_ENSHURE(!mkey1.closeKey(), "testMerge error 23"); + + VOS_ENSHURE(!key1.closeKey(), "testMerge error 24"); + + /////////////////////////////////////////////////////////////////////////// + + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/stardiv/IchbineinMergeKey"), key2), "testMerge error 25"); + + VOS_ENSHURE(!key2.openKey(OUString::createFromAscii("MergeKey2"), mkey2), "testMerge error 26"); + VOS_ENSHURE(!mkey2.closeKey(), "testMerge error 27"); + + VOS_ENSHURE(!key2.openKey(OUString::createFromAscii("/MergeKey2/MK2SubKey1"), mkey2), "testMerge error 28"); + VOS_ENSHURE(!mkey2.closeKey(), "testMerge error 29"); + VOS_ENSHURE(!key2.openKey(OUString::createFromAscii("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), mkey2), "testMerge error 30"); + VOS_ENSHURE(!mkey2.closeKey(), "testMerge error 31"); + + VOS_ENSHURE(!key2.openKey(OUString::createFromAscii("/MergeKey2/MK2SubKey2"), mkey2), "testMerge error 31"); + VOS_ENSHURE(!mkey2.closeKey(), "testMerge error 33"); + VOS_ENSHURE(!key2.openKey(OUString::createFromAscii("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), mkey2), "testMerge error 34"); + VOS_ENSHURE(!mkey2.closeKey(), "testMerge error 35"); + + VOS_ENSHURE(!key2.openKey(OUString::createFromAscii("/MergeKey2/MK2SubKey3"), mkey2), "testMerge error 36"); + VOS_ENSHURE(!mkey2.closeKey(), "testMerge error 37"); + VOS_ENSHURE(!key2.openKey(OUString::createFromAscii("/MergeKey2/MK2SubKey3/KeyWithStringValue"), mkey2), "testMerge error 38"); + VOS_ENSHURE(!mkey2.closeKey(), "testMerge error 39"); + + VOS_ENSHURE(!key2.openKey(OUString::createFromAscii("/MergeKey2/MK2SubKey4"), mkey2), "testMerge error 40"); + VOS_ENSHURE(!mkey2.closeKey(), "testMerge error 41"); + VOS_ENSHURE(!key2.openKey(OUString::createFromAscii("/MergeKey2/MK2SubKey4/KeyWithLongValue"), mkey2), "testMerge error 42"); + VOS_ENSHURE(!mkey2.closeKey(), "testMerge error 43"); + + VOS_ENSHURE(!key2.closeKey(), "testMerge error 44"); + + /////////////////////////////////////////////////////////////////////////// + + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/stardiv/IchbineinMergeKey"), key1u2), "testMerge error 40"); + + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("MergeKey1u2"), mkey1u2), "testMerge error 41"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 42"); + + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey11"), mkey1u2), "testMerge error 43"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 44"); + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), mkey1u2), "testMerge error 45"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 46"); + + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey12"), mkey1u2), "testMerge error 47"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 48"); + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), mkey1u2), "testMerge error 49"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 50"); + + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey13"), mkey1u2), "testMerge error 51"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 52"); + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), mkey1u2), "testMerge error 53"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 54"); + + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey21"), mkey1u2), "testMerge error 55"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 56"); + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), mkey1u2), "testMerge error 57"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 58"); + + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey22"), mkey1u2), "testMerge error 59"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 60"); + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), mkey1u2), "testMerge error 61"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 62"); + + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey23"), mkey1u2), "testMerge error 63"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 64"); + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), mkey1u2), "testMerge error 65"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 66"); + + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK12SubKey1u2"), mkey1u2), "testMerge error 67"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 68"); + VOS_ENSHURE(!key1u2.openKey(OUString::createFromAscii("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), mkey1u2), "testMerge error 69"); + VOS_ENSHURE(!mkey1u2.closeKey(), "testMerge error 70"); + + VOS_ENSHURE(!key1u2.closeKey(), "testMerge error 71"); + + /////////////////////////////////////////////////////////////////////////// + + RegValueType valueType; + sal_uInt32 valueSize; + sal_Int32 int32Value; + sal_uInt8 *Value; + + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/stardiv/IchbineinMergeKey"), key1), "testMerge error 72"); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1/MK1SubKey1/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 73"); + VOS_ENSHURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 74"); + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1/MK1SubKey1/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 74.a)"); + VOS_ENSHURE(int32Value == lValue1, "testMerge error 74.b)"); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1/MK1SubKey2/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 75"); + VOS_ENSHURE(valueType == RG_VALUETYPE_STRING && valueSize == strlen(sValue)+1, "testMerge error 76"); + Value = new sal_uInt8[valueSize]; + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1/MK1SubKey2/KeyWithStringValue"), (RegValue)Value), "testMerge error 76.a)"); + VOS_ENSHURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 76.b)"); + delete(Value); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 77"); + VOS_ENSHURE(valueType == RG_VALUETYPE_UNICODE && valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 78"); + Value = new sal_uInt8[valueSize]; + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 78.a)"); + VOS_ENSHURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 78.b)"); + delete(Value); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 79"); + VOS_ENSHURE(valueType == RG_VALUETYPE_BINARY && valueSize == 27, "testMerge error 80"); + Value = new sal_uInt8[valueSize]; + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 80.a)"); + VOS_ENSHURE(strcmp((const sal_Char*)Value, "abcdefghijklmnopqrstuvwxyz") == 0, "testMerge error 80.b)"); + delete(Value); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 81"); + VOS_ENSHURE(valueType == RG_VALUETYPE_BINARY && valueSize == 11, "testMerge error 82"); + Value = new sal_uInt8[valueSize]; + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 82.a)"); + VOS_ENSHURE(strcmp((const sal_Char*)Value, "1234567890") == 0, "testMerge error 82.b)"); + delete(Value); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 83"); + VOS_ENSHURE(valueType == RG_VALUETYPE_UNICODE&& valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 84"); + Value = new sal_uInt8[valueSize]; + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 84.a)"); + VOS_ENSHURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 84.b)"); + delete(Value); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey2/MK2SubKey3/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 85"); + VOS_ENSHURE(valueType == RG_VALUETYPE_STRING && valueSize == strlen(sValue)+1, "testMerge error 86"); + Value = new sal_uInt8[valueSize]; + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey2/MK2SubKey3/KeyWithStringValue"), (RegValue)Value), "testMerge error 86.a)"); + VOS_ENSHURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 86.b)"); + delete(Value); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey2/MK2SubKey4/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 87"); + VOS_ENSHURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 88"); + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey2/MK2SubKey4/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 88.a)"); + VOS_ENSHURE(int32Value == lValue1, "testMerge error 88.b)"); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 89"); + VOS_ENSHURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 90"); + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 90.a)"); + VOS_ENSHURE(int32Value == lValue2, "testMerge error 90.b)"); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 91"); + VOS_ENSHURE(valueType == RG_VALUETYPE_STRING && valueSize == strlen(sValue)+1, "testMerge error 92"); + Value = new sal_uInt8[valueSize]; + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), (RegValue)Value), "testMerge error 92.a)"); + VOS_ENSHURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 92.b)"); + delete(Value); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 93"); + VOS_ENSHURE(valueType == RG_VALUETYPE_UNICODE && valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 94"); + Value = new sal_uInt8[valueSize]; + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 94.a)"); + VOS_ENSHURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 94.b)"); + delete(Value); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 95"); + VOS_ENSHURE(valueType == RG_VALUETYPE_BINARY && valueSize == 19, "testMerge error 96"); + Value = new sal_uInt8[valueSize]; + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 96.a)"); + VOS_ENSHURE(strcmp((const sal_Char*)Value, "a1b2c3d4e5f6g7h8i9") == 0, "testMerge error 96.b)"); + delete(Value); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 97"); + VOS_ENSHURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 98"); + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 98.a)"); + VOS_ENSHURE(int32Value == lValue2, "testMerge error 98.b)"); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 99"); + VOS_ENSHURE(valueType == RG_VALUETYPE_STRING && valueSize == strlen(sValue)+1, "testMerge error 100"); + Value = new sal_uInt8[valueSize]; + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), (RegValue)Value), "testMerge error 100.a)"); + VOS_ENSHURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 100.b)"); + delete(Value); + + VOS_ENSHURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 101"); + VOS_ENSHURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 102"); + VOS_ENSHURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 102.a)"); + VOS_ENSHURE(int32Value == lValue4, "testMerge error 102.b)"); + + + VOS_ENSHURE(!key1.closeKey(), "testMerge error 24"); + + /////////////////////////////////////////////////////////////////////////// + + VOS_ENSHURE(!rootKey.closeKey(), "testMerge error 10"); + + VOS_ENSHURE(!myRegistry->destroy( OUString::createFromAscii("merge1.rdb") ), "test_registry_CppApi error 11"); + VOS_ENSHURE(!myRegistry->destroy( OUString::createFromAscii("merge2.rdb") ), "test_registry_CppApi error 12"); + VOS_ENSHURE(!myRegistry->destroy( OUString() ), "test_registry_CppApi error 13"); + + delete(myRegistry); + + cout << "test_merge() Ok!\n"; + return; +} + + diff --git a/registry/test/testregcpp.cxx b/registry/test/testregcpp.cxx new file mode 100644 index 000000000000..ffdbdb8d721e --- /dev/null +++ b/registry/test/testregcpp.cxx @@ -0,0 +1,738 @@ +/************************************************************************* + * + * $RCSfile: testregcpp.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <iostream.h> +#include <stdio.h> +#include <string.h> + +#include "registry/registry.hxx" +#include "registry/reflread.hxx" +#include "registry/reflwrit.hxx" + + +#ifndef _VOS_MODULE_HXX +#include <vos/module.hxx> +#endif + +#ifndef _VOS_DIAGNOSE_HXX +#include <vos/diagnose.hxx> +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +using namespace rtl; + +void test_coreReflection() +{ + RegistryLoader* pLoader = new RegistryLoader(); + + if (!pLoader->isLoaded()) + { + delete pLoader; + return; + } + + RegistryTypeWriterLoader* pWriterLoader = new RegistryTypeWriterLoader(); + + if (!pWriterLoader->isLoaded()) + { + delete pWriterLoader; + return; + } + + RegistryTypeReaderLoader* pReaderLoader = new RegistryTypeReaderLoader(); + + if (!pReaderLoader->isLoaded()) + { + delete pReaderLoader; + return; + } + + Registry *myRegistry = new Registry(*pLoader); + delete pLoader; + + RegistryKey rootKey, key1, key2, key3, key4 ,key5, key6, key7, key8; + + VOS_ENSHURE(!myRegistry->create(OUString::createFromAscii("ucrtest.rdb")), "testCoreReflection error 1"); + VOS_ENSHURE(!myRegistry->openRootKey(rootKey), "testCoreReflection error 2"); + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("UCR"), key1), "testCoreReflection error 3"); + VOS_ENSHURE(!key1.createKey(OUString::createFromAscii("ModuleA"), key2), "testCoreReflection error 4"); + VOS_ENSHURE(!key2.createKey(OUString::createFromAscii("StructA"), key3), "testCoreReflection error 5"); + VOS_ENSHURE(!key2.createKey(OUString::createFromAscii("EnumA"), key4), "testCoreReflection error 6"); + VOS_ENSHURE(!key2.createKey(OUString::createFromAscii("XInterfaceA"), key5), "testCoreReflection error 7"); + VOS_ENSHURE(!key2.createKey(OUString::createFromAscii("ExceptionA"), key6), "testCoreReflection error 8"); + VOS_ENSHURE(!key2.createKey(OUString::createFromAscii("ServiceA"), key7), "testCoreReflection error 8a"); + VOS_ENSHURE(!key2.createKey(OUString::createFromAscii("ConstantsA"), key8), "testCoreReflection error 8b"); + + { + RegistryTypeWriter writer(*pWriterLoader, + RT_TYPE_MODULE, + OUString::createFromAscii("ModuleA"), + OUString(), 9, 0, 0); + + RTConstValue aConst; + + writer.setDoku(OUString::createFromAscii("Hallo ich bin ein Modul")); + writer.setFileName(OUString::createFromAscii("DummyFile")); + + aConst.m_type = RT_TYPE_BOOL; + aConst.m_value.aBool = sal_True; + writer.setFieldData(0, OUString::createFromAscii("aConstBool"), + OUString::createFromAscii("boolean"), + OUString::createFromAscii("ich bin ein boolean"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + aConst.m_type = RT_TYPE_BYTE; + aConst.m_value.aByte = 127; + writer.setFieldData(1, OUString::createFromAscii("aConstByte"), + OUString::createFromAscii("byte"), + OUString::createFromAscii("ich bin ein byte"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + aConst.m_type = RT_TYPE_INT16; + aConst.m_value.aShort = -10; + writer.setFieldData(2, OUString::createFromAscii("aConstShort"), + OUString::createFromAscii("short"), + OUString::createFromAscii("ich bin ein short"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + aConst.m_type = RT_TYPE_UINT16; + aConst.m_value.aUShort = 10; + writer.setFieldData(3, OUString::createFromAscii("aConstUShort"), + OUString::createFromAscii("unsigned short"), + OUString::createFromAscii("ich bin ein unsigned short"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + aConst.m_type = RT_TYPE_INT32; + aConst.m_value.aLong = -100000; + writer.setFieldData(4, OUString::createFromAscii("aConstLong"), + OUString::createFromAscii("long"), + OUString::createFromAscii("ich bin ein long"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + aConst.m_type = RT_TYPE_UINT32; + aConst.m_value.aULong = 100000; + writer.setFieldData(5, OUString::createFromAscii("aConstULong"), + OUString::createFromAscii("unsigned long"), + OUString::createFromAscii("ich bin ein unsigned long"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + aConst.m_type = RT_TYPE_FLOAT; + aConst.m_value.aFloat = -2e-10f; + writer.setFieldData(6, OUString::createFromAscii("aConstFloat"), + OUString::createFromAscii("float"), + OUString::createFromAscii("ich bin ein float"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + aConst.m_type = RT_TYPE_DOUBLE; + aConst.m_value.aDouble = -2e-100; writer.setFieldData(7, OUString::createFromAscii("aConstDouble"), + OUString::createFromAscii("double"), + OUString::createFromAscii("ich bin ein double"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + aConst.m_type = RT_TYPE_STRING; + OUString tmpStr(OUString::createFromAscii( "dies ist ein unicode string" )); + aConst.m_value.aString = tmpStr.getStr(); + + writer.setFieldData(8, OUString::createFromAscii("aConstString"), + OUString::createFromAscii("string"), + OUString::createFromAscii("ich bin ein string"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + + const sal_uInt8* pBlop = writer.getBlop(); + sal_uInt32 aBlopSize = writer.getBlopSize(); + + VOS_ENSHURE(!key2.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9"); + + sal_uInt8* readBlop = (sal_uInt8*)rtl_allocateMemory(aBlopSize); + VOS_ENSHURE(!key2.getValue(OUString(), (void*)readBlop) , "testCoreReflection error 9a"); + + RegistryTypeReader reader(*pReaderLoader, readBlop, aBlopSize, sal_True); + + if (reader.isValid()) + { + RTConstValue aReadConst = reader.getFieldConstValue(8); + OString aConstStr = OUStringToOString(aConst.m_value.aString, RTL_TEXTENCODING_ASCII_US); + VOS_ENSHURE(aConstStr.equals("dies ist ein unicode string"), "testCoreReflection error 9b"); + } + + } + + { + RegistryTypeWriter writer(*pWriterLoader, + RT_TYPE_STRUCT, + OUString::createFromAscii("ModuleA/StructA"), + OUString(), 3, 0, 0); + + writer.setDoku(OUString::createFromAscii("Hallo ich bin eine Struktur")); + writer.setFileName(OUString::createFromAscii("DummyFile")); + + writer.setFieldData(0, OUString::createFromAscii("asal_uInt32"), + OUString::createFromAscii("unsigned long"), + OUString(), OUString(), RT_ACCESS_READWRITE); + writer.setFieldData(1, OUString::createFromAscii("aXInterface"), + OUString::createFromAscii("stardiv/uno/XInterface"), + OUString(), OUString(), RT_ACCESS_READWRITE); + writer.setFieldData(2, OUString::createFromAscii("aSequence"), + OUString::createFromAscii("[]ModuleA/EnumA"), + OUString(), OUString(), RT_ACCESS_READWRITE); + + const sal_uInt8* pBlop = writer.getBlop(); + sal_uInt32 aBlopSize = writer.getBlopSize(); + + VOS_ENSHURE(!key3.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9a"); + } + + { + RegistryTypeWriter writer(*pWriterLoader, + RT_TYPE_ENUM, + OUString::createFromAscii("ModuleA/EnumA"), + OUString(), 2, 0, 0); + + RTConstValue aConst; + + aConst.m_type = RT_TYPE_UINT32; + aConst.m_value.aULong = 10; + + writer.setDoku(OUString::createFromAscii("Hallo ich bin ein Enum")); + writer.setFileName(OUString::createFromAscii("DummyFile")); + + writer.setFieldData(0, OUString::createFromAscii("ENUM_VAL_1"), + OUString(), OUString::createFromAscii("ich bin ein enum value"), + OUString(), RT_ACCESS_CONST, aConst); + + aConst.m_value.aULong = 10; + writer.setFieldData(1, OUString::createFromAscii("ENUM_VAL_2"), + OUString(), OUString(), OUString(), RT_ACCESS_CONST, aConst); + + const sal_uInt8* pBlop = writer.getBlop(); + sal_uInt32 aBlopSize = writer.getBlopSize(); + + VOS_ENSHURE(!key4.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9b"); + } + + { + RegistryTypeWriter writer(*pWriterLoader, + RT_TYPE_INTERFACE, + OUString::createFromAscii("ModuleA/XInterfaceA"), + OUString::createFromAscii("stardiv/uno/XInterface"), + 4, 1, 0); + RTConstValue aConst; + + RTUik aUik = {1,2,3,4,5}; + + writer.setUik(aUik); + writer.setDoku(OUString::createFromAscii("Hallo ich bin ein Interface")); + writer.setFileName(OUString::createFromAscii("DummyFile")); + + writer.setFieldData(0, OUString::createFromAscii("aString"), + OUString::createFromAscii("string"), OUString(), OUString(), RT_ACCESS_READWRITE); + writer.setFieldData(1, OUString::createFromAscii("aStruct"), + OUString::createFromAscii("ModuleA/StructA"), + OUString(), OUString(), RT_ACCESS_READONLY); + writer.setFieldData(2, OUString::createFromAscii("aEnum"), + OUString::createFromAscii("ModuleA/EnumA"), OUString(), OUString(), RT_ACCESS_BOUND); + aConst.m_type = RT_TYPE_UINT16; + aConst.m_value.aUShort = 12; + writer.setFieldData(3, OUString::createFromAscii("aConstUShort"), + OUString::createFromAscii("unsigned short"), OUString(), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + + writer.setMethodData(0, OUString::createFromAscii("methodA"), + OUString::createFromAscii("double"), RT_MODE_TWOWAY, 2, 1, + OUString::createFromAscii("Hallo ich bin die methodA")); + writer.setParamData(0, 0, OUString::createFromAscii("ModuleA/StructA"), + OUString::createFromAscii("aStruct"), RT_PARAM_IN); + writer.setParamData(0, 1, OUString::createFromAscii("unsigned short"), + OUString::createFromAscii("aShort"), RT_PARAM_INOUT); + writer.setExcData(0, 0, OUString::createFromAscii("ModuleA/ExceptionA")); + + const sal_uInt8* pBlop = writer.getBlop(); + sal_uInt32 aBlopSize = writer.getBlopSize(); + + VOS_ENSHURE(!key5.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9c"); + } + + { + RegistryTypeWriter writer(*pWriterLoader, + RT_TYPE_EXCEPTION, + OUString::createFromAscii("ModuleA/ExceptionA"), + OUString(), 1, 0, 0); + + writer.setDoku(OUString::createFromAscii("Hallo ich bin eine Exception")); + + writer.setFieldData(0, OUString::createFromAscii("aSource"), + OUString::createFromAscii("stardiv/uno/XInterface"), + OUString::createFromAscii("ich bin ein interface member"), + OUString(), RT_ACCESS_READWRITE); + + const sal_uInt8* pBlop = writer.getBlop(); + sal_uInt32 aBlopSize = writer.getBlopSize(); + + VOS_ENSHURE(!key6.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9d"); + } + + { + RegistryTypeWriter writer(*pWriterLoader, + RT_TYPE_SERVICE, + OUString::createFromAscii("ModuleA/ServiceA"), + OUString(), 1, 0, 4); + + writer.setDoku(OUString::createFromAscii("Hallo ich bin ein Service")); + writer.setFileName(OUString::createFromAscii("DummyFile")); + + writer.setFieldData(0, OUString::createFromAscii("aProperty"), + OUString::createFromAscii("stardiv/uno/XInterface"), + OUString::createFromAscii("ich bin eine property"), + OUString(), RT_ACCESS_READWRITE); + + writer.setReferenceData(0, OUString::createFromAscii("ModuleA/XInterfaceA"), RT_REF_SUPPORTS, + OUString::createFromAscii("Hallo ich eine Reference auf ein supported interface"), + RT_ACCESS_OPTIONAL); + writer.setReferenceData(1, OUString::createFromAscii("ModuleA/XInterfaceA"), RT_REF_OBSERVES, + OUString::createFromAscii("Hallo ich eine Reference auf ein observed interface")); + writer.setReferenceData(2, OUString::createFromAscii("ModuleA/ServiceB"), RT_REF_EXPORTS, + OUString::createFromAscii("Hallo ich eine Reference auf einen exported service")); + writer.setReferenceData(3, OUString::createFromAscii("ModuleA/ServiceB"), RT_REF_NEEDS, + OUString::createFromAscii("Hallo ich eine Reference auf einen needed service")); + + const sal_uInt8* pBlop = writer.getBlop(); + sal_uInt32 aBlopSize = writer.getBlopSize(); + + VOS_ENSHURE(!key7.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9e"); + } + + { + RegistryTypeWriter writer(*pWriterLoader, + RT_TYPE_CONSTANTS, + OUString::createFromAscii("ModuleA/ConstansA"), + OUString(), 3, 0, 0); + + RTConstValue aConst; + + writer.setDoku(OUString::createFromAscii("Hallo ich bin eine Constants Group")); + writer.setFileName(OUString::createFromAscii("DummyFile")); + + aConst.m_type = RT_TYPE_BOOL; + aConst.m_value.aBool = sal_True; + writer.setFieldData(0, OUString::createFromAscii("ConstantsA_aConstBool"), + OUString::createFromAscii("boolean"), + OUString::createFromAscii("ich bin ein boolean"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + aConst.m_type = RT_TYPE_BYTE; + aConst.m_value.aByte = 127; + writer.setFieldData(1, OUString::createFromAscii("ConstantsA_aConstByte"), + OUString::createFromAscii("byte"), + OUString::createFromAscii("ich bin ein byte"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + aConst.m_type = RT_TYPE_INT16; + aConst.m_value.aShort = -10; + writer.setFieldData(2, OUString::createFromAscii("ConstantsA_aConstShort"), + OUString::createFromAscii("short"), + OUString::createFromAscii("ich bin ein short"), + OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); + + const sal_uInt8* pBlop = writer.getBlop(); + sal_uInt32 aBlopSize = writer.getBlopSize(); + + VOS_ENSHURE(!key8.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9f"); + } + + delete pWriterLoader; + +// VOS_ENSHURE(!myRegistry->destroy(NULL), "testCoreReflection error 10"); + delete myRegistry; + + cout << "test_coreReflection() Ok!\n"; +} + +void test_registry_CppApi() +{ + RegistryLoader* pLoader = new RegistryLoader(); + + if (!pLoader->isLoaded()) + { + delete pLoader; + return; + } + + Registry *myRegistry = new Registry(*pLoader); + delete pLoader; + + RegistryKey rootKey, key1, key2, key3, key4 ,key5, key6, key7, key8, key9; + + VOS_ENSHURE(!myRegistry->create(OUString::createFromAscii("test.rdb")), "test_registry_CppApi error 1"); + VOS_ENSHURE(!myRegistry->openRootKey(rootKey), "test_registry_CppApi error 2"); + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("myFirstKey"), key1), "test_registry_CppApi error 3"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("mySecondKey"), key2), "test_registry_CppApi error 4"); + VOS_ENSHURE(!key1.createKey(OUString::createFromAscii("X"), key3), "test_registry_CppApi error 5"); + VOS_ENSHURE(!key1.createKey(OUString::createFromAscii("mySecondSubKey"), key4), "test_registry_CppApi error 6"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("myThirdKey"), key5), "test_registry_CppApi error 6a"); + + VOS_ENSHURE(!key5.createKey(OUString::createFromAscii("1"), key4), "test_registry_CppApi error 6b"); + VOS_ENSHURE(!key4.createKey(OUString::createFromAscii("2"), key3), "test_registry_CppApi error 6c"); + VOS_ENSHURE(!key5.openKey(OUString::createFromAscii("1"), key4), "test_registry_CppApi error 6d"); + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/myThirdKey/1"), key4), "test_registry_CppApi error 6e"); + VOS_ENSHURE(key4.getName().equals(OUString::createFromAscii("/myThirdKey/1")), "test_registry_CppApi error 6f"); + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("myFourthKey"), key6), "test_registry_CppApi error 7"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("myFifthKey"), key6), "test_registry_CppApi error 7a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("mySixthKey"), key6), "test_registry_CppApi error 7b"); + + // Link Test + // + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/myFourthKey/X"), key7), "test_registry_CppApi error 7c)");; + VOS_ENSHURE(!key6.createLink(OUString::createFromAscii("myFirstLink"), OUString::createFromAscii("/myFourthKey/X")), "test_registry_CppApi error 7d"); + VOS_ENSHURE(!key6.createKey(OUString::createFromAscii("mySixthSubKey"), key7), "test_registry_CppApi error 7e"); + + OUString linkTarget; + VOS_ENSHURE(!key6.getLinkTarget(OUString::createFromAscii("myFirstLink"), linkTarget), "test_registry_CppApi error 7f"); + VOS_ENSHURE(linkTarget.equals(OUString::createFromAscii("/myFourthKey/X")), "test_registry_CppApi error 7g"); + + RegistryKeyNames* pSubKeyNames = new RegistryKeyNames(); + sal_uInt32 nSubKeys=0; + + VOS_ENSHURE(!rootKey.getKeyNames(OUString::createFromAscii("mySixthKey"), *pSubKeyNames), "test_registry_CppApi error 7h)"); + VOS_ENSHURE(pSubKeyNames->getLength() == 2, "test_registry_CppApi error 7i)"); + + for (sal_uInt32 i=0; i < pSubKeyNames->getLength(); i++) + { + if (pSubKeyNames->getElement(i).equals(OUString::createFromAscii("/mySixthKey/myFirstLink"))) + { + RegKeyType keyType; + VOS_ENSHURE(!rootKey.getKeyType(pSubKeyNames->getElement(i), &keyType), "test_registry_CppApi error 7j"); + VOS_ENSHURE(keyType == RG_LINKTYPE, "test_registry_CppApi error 7k"); + } + } + + VOS_ENSHURE(!key7.closeKey(), "test_registry_CppApi error 7k1"); + delete pSubKeyNames; + + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/mySixthKey/myFirstLink"), key6), "test_registry_CppApi error 7l"); + VOS_ENSHURE(key6.getName().equals(OUString::createFromAscii("/myFourthKey/X")), "test_registry_CppApi error 7m"); + + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("myFifthKey"), key6), "test_registry_CppApi error 7m1"); + VOS_ENSHURE(!key6.createLink(OUString::createFromAscii("mySecondLink"), + OUString::createFromAscii("/mySixthKey/myFirstLink")), "test_registry_CppApi error 7m2"); + + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/myFifthKey/mySecondLink"), key6), "test_registry_CppApi error 7m3"); + VOS_ENSHURE(key6.getName().equals(OUString::createFromAscii("/myFourthKey/X")), "test_registry_CppApi error 7m4"); + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/myFifthKey/mySecondLink/myFirstLinkSubKey"), key7), "test_registry_CppApi error 7m5"); + VOS_ENSHURE(key7.getName().equals(OUString::createFromAscii("/myFourthKey/X/myFirstLinkSubKey")), "test_registry_CppApi error 7m6"); + + VOS_ENSHURE(!key7.createLink(OUString::createFromAscii("myThirdLink"), OUString::createFromAscii("/myFifthKey/mySecondLink")), "test_registry_CppApi error 7m7"); + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/myFourthKey/X/myFirstLinkSubKey/myThirdLink"), key7), "test_registry_CppApi error 7m8"); + VOS_ENSHURE(!key7.openKey(OUString::createFromAscii("/myFirstLinkSubKey/myThirdLink/myFirstLinkSubKey/myThirdLink"), key6), "test_registry_CppApi error 7m9"); + VOS_ENSHURE(key7.getName().equals(OUString::createFromAscii("/myFourthKey/X")), "test_registry_CppApi error 7m10"); + VOS_ENSHURE(!key7.closeKey(), "test_registry_CppApi error 7m11"); + + VOS_ENSHURE(!rootKey.deleteLink(OUString::createFromAscii("/myFifthKey/mySecondLink")), "test_registry_CppApi error 7m12"); + + VOS_ENSHURE(!rootKey.createLink(OUString::createFromAscii("/myFifthKey/mySecondLink"), + OUString::createFromAscii("/myFourthKey/X/myFirstLinkSubKey/myThirdLink")), + "test_registry_CppApi error 7m13"); + + VOS_ENSHURE(rootKey.openKey(OUString::createFromAscii("/myFourthKey/X/myFirstLinkSubKey/myThirdLink"), key7) == REG_DETECT_RECURSION, + "test_registry_CppApi error 7m14"); + + VOS_ENSHURE(key7.closeKey() == REG_INVALID_KEY, "test_registry_CppApi error 7m11"); + + RegistryKeyNames subKeyNames; + nSubKeys=0; + + VOS_ENSHURE(!rootKey.getKeyNames(OUString::createFromAscii("mySixthKey"), subKeyNames), "test_registry_CppApi error 7n"); + + nSubKeys = subKeyNames.getLength(); + VOS_ENSHURE(nSubKeys == 2, "test_registry_CppApi error 7n1"); + VOS_ENSHURE(subKeyNames.getElement(0).equals(OUString::createFromAscii("/mySixthKey/myFirstLink")), "test_registry_CppApi error 7p1)"); + VOS_ENSHURE(subKeyNames.getElement(1).equals(OUString::createFromAscii("/mySixthKey/mySixthSubKey")), "test_registry_CppApi error 7p2"); + + + RegistryKeyArray subKeys; + nSubKeys=0; + + VOS_ENSHURE(!rootKey.openSubKeys(OUString::createFromAscii("myFirstKey"), subKeys), "test_registry_CppApi error 7o"); + + nSubKeys = subKeys.getLength(); + VOS_ENSHURE(nSubKeys == 2, "test_registry_CppApi error 7o1"); + VOS_ENSHURE(subKeys.getElement(0).getName().equals(OUString::createFromAscii("/myFirstKey/mySecondSubKey")), "test_registry_CppApi error 7p1)"); + VOS_ENSHURE(subKeys.getElement(1).getName().equals(OUString::createFromAscii("/myFirstKey/X")), "test_registry_CppApi error 7p2"); + + VOS_ENSHURE(!rootKey.closeSubKeys(subKeys), "test_registry_CppApi error 7q)"); + + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/TEST"), key8), "test_registry_CppApi error 8"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/TEST/Child1"), key8), "test_registry_CppApi error 8a"); + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("/TEST/Child2"), key8), "test_registry_CppApi error 8a1"); + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/TEST"), key9), "test_registry_CppApi error 8b"); + VOS_ENSHURE(!key8.closeKey() && !key9.closeKey(), "test_registry_CppApi error 8b1"); + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/TEST"), key8), "test_registry_CppApi error 8b"); + VOS_ENSHURE(!key8.closeKey(), "test_registry_CppApi error 8c"); + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("TEST"), key8), "test_registry_CppApi error 8c"); + VOS_ENSHURE(!key8.closeKey(), "test_registry_CppApi error 8d"); + + + sal_Char* Value="Mein erster Value"; + VOS_ENSHURE(!rootKey.setValue(OUString::createFromAscii("mySecondKey"), RG_VALUETYPE_STRING, Value, 18), "test_registry_CppApi error 9"); + + RegValueType valueType; + sal_uInt32 valueSize; + sal_Char* readValue; + VOS_ENSHURE(!rootKey.getValueInfo(OUString::createFromAscii("mySecondKey"), &valueType, &valueSize), "test_registry_CppApi error 9a"); + + readValue = (sal_Char*)rtl_allocateMemory(valueSize); + VOS_ENSHURE(!key2.getValue(OUString(), readValue), "test_registry_CppApi error 10"); + + VOS_ENSHURE(valueType == RG_VALUETYPE_STRING, "test_registry_CppApi error 11"); + VOS_ENSHURE(valueSize == 18, "test_registry_CppApi error 12"); + VOS_ENSHURE(strcmp(readValue, Value) == 0, "test_registry_CppApi error 13"); + rtl_freeMemory(readValue); + + const sal_Char* pList[3]; + const sal_Char* n1= "Hallo"; + const sal_Char* n2= "jetzt komm"; + const sal_Char* n3= "ich"; + + pList[0]=n1; + pList[1]=n2; + pList[2]=n3; + + VOS_ENSHURE(!rootKey.setStringListValue(OUString::createFromAscii("myFourthKey"), (sal_Char**)pList, 3), "test_registry_CppApi error 13a"); + + RegistryValueList<sal_Char*> valueList; + VOS_ENSHURE(!rootKey.getStringListValue(OUString::createFromAscii("myFourthKey"), valueList), "test_registry_CppApi error 13b"); + + VOS_ENSHURE(strcmp(n1, valueList.getElement(0)) == 0, "test_registry_CppApi error 13c"); + VOS_ENSHURE(strcmp(n2, valueList.getElement(1)) == 0, "test_registry_CppApi error 13d"); + VOS_ENSHURE(strcmp(n3, valueList.getElement(2)) == 0, "test_registry_CppApi error 13e"); + + VOS_ENSHURE(!rootKey.getValueInfo(OUString::createFromAscii("myFourthKey"), &valueType, &valueSize), "test_registry_CppApi error 13e1"); + VOS_ENSHURE(valueType == RG_VALUETYPE_STRINGLIST, "test_registry_CppApi error 13e2"); + VOS_ENSHURE(valueSize == 3, "test_registry_CppApi error 13e3"); + + sal_Int32 pLong[3]; + pLong[0] = 123; + pLong[1] = 456; + pLong[2] = 789; + + VOS_ENSHURE(!rootKey.setLongListValue(OUString::createFromAscii("myFifthKey"), pLong, 3), "test_registry_CppApi error 13f"); + + RegistryValueList<sal_Int32> longList; + VOS_ENSHURE(!rootKey.getLongListValue(OUString::createFromAscii("myFifthKey"), longList), "test_registry_CppApi error 13g"); + + VOS_ENSHURE(pLong[0] == longList.getElement(0), "test_registry_CppApi error 13h"); + VOS_ENSHURE(pLong[1] == longList.getElement(1), "test_registry_CppApi error 13i"); + VOS_ENSHURE(pLong[2] == longList.getElement(2), "test_registry_CppApi error 13j"); + + + OUString sWTestValue(OUString::createFromAscii( "Mein erster Unicode Value" )); + const sal_Unicode* wTestValue= sWTestValue.getStr(); + VOS_ENSHURE(!rootKey.setValue(OUString::createFromAscii("mySixthKey"), RG_VALUETYPE_UNICODE, (void*)wTestValue, + (rtl_ustr_getLength(wTestValue)+1)*sizeof(sal_Unicode)), "test_registry_CppApi error 13j1"); + + VOS_ENSHURE(!rootKey.getValueInfo(OUString::createFromAscii("mySixthKey"), &valueType, &valueSize), "test_registry_CppApi error 13j2"); + sal_Unicode* pTmpValue = (sal_Unicode*)rtl_allocateMemory(valueSize); + VOS_ENSHURE(!rootKey.getValue(OUString::createFromAscii("mySixthKey"), pTmpValue), "test_registry_CppApi error 13j3"); + VOS_ENSHURE(rtl_ustr_getLength(wTestValue) == rtl_ustr_getLength(pTmpValue), "test_registry_CppApi error 13j4"); + VOS_ENSHURE(rtl_ustr_compare(wTestValue, pTmpValue) == 0, "test_registry_CppApi error 13j4"); + + const sal_Unicode* pUnicode[3]; + OUString w1(OUString::createFromAscii( "Hallo" )); + OUString w2(OUString::createFromAscii( "jetzt komm" )); + OUString w3(OUString::createFromAscii( "ich als unicode" )); + + pUnicode[0]=w1.getStr(); + pUnicode[1]=w2.getStr(); + pUnicode[2]=w3.getStr(); + + VOS_ENSHURE(!rootKey.setUnicodeListValue(OUString::createFromAscii("mySixthKey"), (sal_Unicode**)pUnicode, 3), "test_registry_CppApi error 13k"); + + RegistryValueList<sal_Unicode*> unicodeList; + VOS_ENSHURE(!rootKey.getUnicodeListValue(OUString::createFromAscii("mySixthKey"), unicodeList), "test_registry_CppApi error 13l"); + + VOS_ENSHURE(rtl_ustr_compare(w1, unicodeList.getElement(0)) == 0, "test_registry_CppApi error 13m"); + VOS_ENSHURE(rtl_ustr_compare(w2, unicodeList.getElement(1)) == 0, "test_registry_CppApi error 13n"); + VOS_ENSHURE(rtl_ustr_compare(w3, unicodeList.getElement(2)) == 0, "test_registry_CppApi error 13o"); + + VOS_ENSHURE(!key6.closeKey(), "test_registry_CppApi error 14"); + + VOS_ENSHURE(!key1.closeKey() && + !key3.closeKey() && + !key4.closeKey(), "test_registry_CppApi error 14"); + + VOS_ENSHURE(!rootKey.deleteKey(OUString::createFromAscii("myFirstKey")), "test_registry_CppApi error 15"); + + VOS_ENSHURE(!key2.closeKey(), "test_registry_CppApi error 16"); + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("mySecondKey"), key2), "test_registry_CppApi error 17"); + + VOS_ENSHURE(!key5.closeKey(), "test_registry_CppApi error 18"); + + VOS_ENSHURE(!rootKey.deleteKey(OUString::createFromAscii("myThirdKey")), "test_registry_CppApi error 19"); + + VOS_ENSHURE(rootKey.openKey(OUString::createFromAscii("myThirdKey"), key5), "test_registry_CppApi error 20"); + + VOS_ENSHURE(!key2.closeKey() && + !rootKey.closeKey(), "test_registry_CppApi error 21"); + + VOS_ENSHURE(!myRegistry->close(), "test_registry_CppApi error 22"); + + // Test loadkey + RegistryKey rootKey2, key21, key22, key23, key24 , key25; + + VOS_ENSHURE(!myRegistry->create(OUString::createFromAscii("test2.rdb")), "test_registry_CppApi error 23"); + VOS_ENSHURE(!myRegistry->openRootKey(rootKey2), "test_registry_CppApi error 24"); + + VOS_ENSHURE(!rootKey2.createKey(OUString::createFromAscii("reg2FirstKey"), key21), "test_registry_CppApi error 25"); + VOS_ENSHURE(!rootKey2.createKey(OUString::createFromAscii("reg2SecondKey"), key22), "test_registry_CppApi error 26"); + VOS_ENSHURE(!key21.createKey(OUString::createFromAscii("reg2FirstSubKey"), key23), "test_registry_CppApi error 27"); + VOS_ENSHURE(!key21.createKey(OUString::createFromAscii("reg2SecondSubKey"), key24), "test_registry_CppApi error 28"); + VOS_ENSHURE(!rootKey2.createKey(OUString::createFromAscii("reg2ThirdKey"), key25), "test_registry_CppApi error 29"); + + sal_uInt32 nValue= 123456789; + VOS_ENSHURE(!key23.setValue(OUString(), RG_VALUETYPE_LONG, &nValue, sizeof(sal_uInt32)), "test_registry_CppApi error 30"); + + VOS_ENSHURE(!key21.closeKey() && + !key22.closeKey() && + !key23.closeKey() && + !key24.closeKey() && + !key25.closeKey() && + !rootKey2.closeKey(), "test_registry_CppApi error 31"); + + VOS_ENSHURE(!myRegistry->close(), "test_registry_CppApi error 32"); + + VOS_ENSHURE(!myRegistry->open(OUString::createFromAscii("test.rdb"), REG_READWRITE), "test_registry_CppApi error 33"); + VOS_ENSHURE(!myRegistry->openRootKey(rootKey), "test_registry_CppApi error 34"); + + VOS_ENSHURE(!myRegistry->loadKey(rootKey, OUString::createFromAscii("allFromTest2"), + OUString::createFromAscii("test2.rdb")), "test_registry_CppApi error 35"); + VOS_ENSHURE(!myRegistry->saveKey(rootKey, OUString::createFromAscii("allFromTest2"), + OUString::createFromAscii("test3.rdb")), "test_registry_CppApi error 36"); + + VOS_ENSHURE(!rootKey.createKey(OUString::createFromAscii("allFromTest3"), key1), "test_registry_CppApi error 37"); + VOS_ENSHURE(!key1.createKey(OUString::createFromAscii("myFirstKey2"), key2), "test_registry_CppApi error 38"); + VOS_ENSHURE(!key1.createKey(OUString::createFromAscii("mySecondKey2"), key3), "test_registry_CppApi error 39"); + + VOS_ENSHURE(!myRegistry->mergeKey(rootKey, OUString::createFromAscii("allFromTest3"), + OUString::createFromAscii("test3.rdb")), "test_registry_CppApi error 40"); + VOS_ENSHURE(!myRegistry->mergeKey(rootKey, OUString::createFromAscii("allFromTest3"), + OUString::createFromAscii("ucrtest.rdb"), sal_True), "test_registry_CppApi error 40.a)"); + + VOS_ENSHURE(myRegistry->mergeKey(rootKey, OUString::createFromAscii("allFromTest3"), OUString::createFromAscii("ucrtest.rdb"), sal_True) + == REG_NO_ERROR/*REG_MERGE_CONFLICT*/, "test_registry_CppApi error 40.b)"); + + VOS_ENSHURE(!key1.closeKey() && + !key2.closeKey(), "test_registry_CppApi error 41"); + + const sal_Unicode* wValue= OUString::createFromAscii( "Mein erster Unicode Value" ).getStr(); + VOS_ENSHURE(!key3.setValue(OUString(), RG_VALUETYPE_UNICODE, (void*)wValue, + (rtl_ustr_getLength(wValue)+1)*sizeof(sal_Unicode)), "test_registry_CppApi error 42"); + + VOS_ENSHURE(!key3.closeKey(), "test_registry_CppApi error 43"); + + VOS_ENSHURE(!rootKey.openKey(OUString::createFromAscii("/allFromTest3/reg2FirstKey/reg2FirstSubKey"), key1), + "test_registry_CppApi error 43.a)"); + VOS_ENSHURE(!rootKey.deleteKey(OUString::createFromAscii("/allFromTest3/reg2FirstKey/reg2FirstSubKey")), "test_registry_CppApi error 44"); + VOS_ENSHURE(key1.getValueInfo(OUString(), &valueType, &valueSize) == REG_INVALID_KEY, + "test_registry_CppApi error 44.a)"); + VOS_ENSHURE(!key1.closeKey(), "test_registry_CppApi error 44.b)"); + + VOS_ENSHURE(!rootKey.closeKey(), "test_registry_CppApi error 45"); + + VOS_ENSHURE(!myRegistry->close(), "test_registry_CppApi error 46"); + + VOS_ENSHURE(!myRegistry->open(OUString::createFromAscii("test.rdb"), REG_READWRITE), "test_registry_CppApi error 47"); + + VOS_ENSHURE(!myRegistry->destroy(OUString::createFromAscii("test2.rdb")), "test_registry_CppApi error 48"); +// VOS_ENSHURE(!myRegistry->destroy("test3.rdb"), "test_registry_CppApi error 49"); + + Registry *myRegistry2 = new Registry(*myRegistry); + + VOS_ENSHURE(myRegistry->destroy(OUString()), "test_registry_CppApi error 50"); + + delete(myRegistry2); + + VOS_ENSHURE(!myRegistry->create(OUString::createFromAscii("destroytest.rdb")), "test_registry_CppApi error 51"); + VOS_ENSHURE(!myRegistry->close(), "test_registry_CppApi error 52"); + VOS_ENSHURE(!myRegistry->open(OUString::createFromAscii("destroytest.rdb"), REG_READONLY), "test_registry_CppApi error 53"); + VOS_ENSHURE(!myRegistry->openRootKey(rootKey), "test_registry_CppApi error 54"); + + VOS_ENSHURE(myRegistry->mergeKey(rootKey, OUString::createFromAscii("allFromTest3"), + OUString::createFromAscii("test3.rdb")), "test_registry_CppApi error 55"); + VOS_ENSHURE(!myRegistry->destroy(OUString::createFromAscii("test3.rdb")), "test_registry_CppApi error 56"); + + VOS_ENSHURE(!rootKey.closeKey(), "test_registry_CppApi error 57"); + VOS_ENSHURE(!myRegistry->close(), "test_registry_CppApi error 58"); + VOS_ENSHURE(!myRegistry->open(OUString::createFromAscii("destroytest.rdb"), REG_READWRITE), "test_registry_CppApi error 59"); + VOS_ENSHURE(!myRegistry->destroy(OUString()), "test_registry_CppApi error 60"); + + VOS_ENSHURE(!myRegistry->open(OUString::createFromAscii("test.rdb"), REG_READWRITE), "test_registry_CppApi error 61"); + VOS_ENSHURE(!myRegistry->destroy(OUString::createFromAscii("ucrtest.rdb")), "test_registry_CppApi error 62"); + VOS_ENSHURE(!myRegistry->destroy(OUString()), "test_registry_CppApi error 63"); + delete(myRegistry); + + cout << "test_registry_CppApi() Ok!\n"; + + return; +} + + diff --git a/registry/tools/makefile.mk b/registry/tools/makefile.mk new file mode 100644 index 000000000000..d08b710076eb --- /dev/null +++ b/registry/tools/makefile.mk @@ -0,0 +1,111 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=.. + +PRJNAME=registry +TARGET=regmerge +TARGETTYPE=CUI +LIBTARGET=NO + +# --- Settings ----------------------------------------------------- +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +.INCLUDE : ..$/version.mk + +# --- Files -------------------------------------------------------- +CDEFS += -DDLL_VERSION=\"$(UPD)$(DLLPOSTFIX)\" + +CXXFILES= regview.cxx \ + regmerge.cxx + + +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJ)$/regmerge.obj + +APP1STDLIBS=\ + $(SALLIB) \ + $(VOSLIB) \ + $(REGLIB) + +.IF "$(GUI)"=="WNT" +APP1STDLIBS+= \ + $(LIBCIMT) $(LIBCMT) +.ENDIF + + +APP2TARGET= regview +APP2OBJS= $(OBJ)$/regview.obj + +APP2STDLIBS=\ + $(SALLIB) \ + $(VOSLIB) \ + $(REGLIB) + +.IF "$(GUI)"=="WNT" +APP2STDLIBS+= \ + $(LIBCIMT) $(LIBCMT) +.ENDIF + +.INCLUDE : target.mk diff --git a/registry/tools/regmerge.cxx b/registry/tools/regmerge.cxx new file mode 100644 index 000000000000..73f530dafceb --- /dev/null +++ b/registry/tools/regmerge.cxx @@ -0,0 +1,217 @@ +/************************************************************************* + * + * $RCSfile: regmerge.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <stdio.h> +#include <string.h> + +#include "registry/registry.h" + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + +int realargc; +char* realargv[2048]; + +static void checkCommandFile(char* cmdfile) +{ + FILE *commandfile; + char option[256]; + + commandfile = fopen(cmdfile+1, "r"); + if( commandfile == NULL ) + { + fprintf(stderr, "ERROR: Can't open command file \"%s\"\n", cmdfile); + } else + { + while ( fscanf(commandfile, "%s", option) != EOF ) + { + if (option[0]== '@') + { + checkCommandFile(option); + } else + { + realargv[realargc]= strdup(option); + realargc++; + } + + if (realargc == 2047) + { + fprintf(stderr, "ERROR: more than 2048 arguments.\n"); + break; + } + } + fclose(commandfile); + } +} + +static void checkCommandArgs(int argc, char **argv) +{ + realargc = 0; + + for (int i=0; i<argc; i++) + { + if (argv[i][0]== '@') + { + checkCommandFile(argv[i]); + } else + { + realargv[i]= strdup(argv[i]); + realargc++; + } + } +} + +static void cleanCommandArgs() +{ + for (int i=0; i<realargc; i++) + { + free(realargv[i]); + } +} + + + +#if (defined UNX) || (defined OS2) +int main( int argc, char * argv[] ) +#else +int _cdecl main( int argc, char * argv[] ) +#endif +{ + RegHandle hReg; + RegKeyHandle hRootKey; + + checkCommandArgs(argc, argv); + + if (realargc < 4) + { + fprintf(stderr, "using: regmerge mergefile mergeKeyName regfile_1 ... regfile_n\n"); + fprintf(stderr, " regmerge @regcmds\n"); + + cleanCommandArgs(); + exit(1); + } + + ::rtl::OUString regName( ::rtl::OUString::createFromAscii(realargv[1]) ); + if (reg_openRegistry(regName.pData, &hReg, REG_READWRITE)) + { + if (reg_createRegistry(regName.pData, &hReg)) + { + fprintf(stderr, "open registry \"%s\" failed\n", realargv[1]); + cleanCommandArgs(); + exit(-1); + } + } + + if (!reg_openRootKey(hReg, &hRootKey)) + { + ::rtl::OUString mergeKeyName( ::rtl::OUString::createFromAscii(realargv[2]) ); + ::rtl::OUString targetRegName; + RegError _ret = REG_NO_ERROR; + for (int i = 3; i < realargc; i++) + { + targetRegName = ::rtl::OUString::createFromAscii(realargv[i]); + if (_ret = reg_mergeKey(hRootKey, mergeKeyName.pData, targetRegName.pData, sal_False, sal_True)) + { + if (_ret == REG_MERGE_CONFLICT) + { + fprintf(stderr, "merging registry \"%s\" under key \"%s\" in registry \"%s\".\n", + realargv[i], realargv[2], realargv[1]); + } else + { + fprintf(stderr, "ERROR: merging registry \"%s\" under key \"%s\" in registry \"%s\" failed.\n", + realargv[i], realargv[2], realargv[1]); + exit(-2); + } + } else + { + fprintf(stderr, "merging registry \"%s\" under key \"%s\" in registry \"%s\".\n", + realargv[i], realargv[2], realargv[1]); + } + } + + if (reg_closeKey(hRootKey)) + { + fprintf(stderr, "closing root key of registry \"%s\" failed\n", realargv[1]); + exit(-3); + } + } else + { + fprintf(stderr, "open root key of registry \"%s\" failed\n", realargv[1]); + exit(-4); + } + + if (reg_closeRegistry(hReg)) + { + fprintf(stderr, "closing registry \"%s\" failed\n", realargv[1]); + cleanCommandArgs(); + exit(-5); + } + + cleanCommandArgs(); + return(0); +} + + diff --git a/registry/tools/regview.cxx b/registry/tools/regview.cxx new file mode 100644 index 000000000000..d488630f6180 --- /dev/null +++ b/registry/tools/regview.cxx @@ -0,0 +1,144 @@ +/************************************************************************* + * + * $RCSfile: regview.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <stdio.h> + +#include "registry/registry.h" + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + +#if (defined UNX) || (defined OS2) +int main( int argc, char * argv[] ) +#else +int _cdecl main( int argc, char * argv[] ) +#endif +{ + RegHandle hReg; + RegKeyHandle hRootKey, hKey; + + if (argc < 2 || argc > 3) + { + fprintf(stderr, "using: regview registryfile [keyName]\n"); + exit(1); + } + + ::rtl::OUString regName( ::rtl::OUString::createFromAscii(argv[1]) ); + if (reg_openRegistry(regName.pData, &hReg, REG_READONLY)) + { + fprintf(stderr, "open registry \"%s\" failed\n", argv[1]); + exit(1); + } + + if (!reg_openRootKey(hReg, &hRootKey)) + { + if (argc == 3) + { + ::rtl::OUString keyName( ::rtl::OUString::createFromAscii(argv[2]) ); + if (!reg_openKey(hRootKey, keyName.pData, &hKey)) + { + if (reg_dumpRegistry(hKey)) + { + fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]); + } + + if (reg_closeKey(hKey)) + { + fprintf(stderr, "closing key \"%s\" of registry \"%s\" failed\n", + argv[2], argv[1]); + } + } else + { + fprintf(stderr, "key \"%s\" not exists in registry \"%s\"\n", + argv[2], argv[1]); + } + } else + { + if (reg_dumpRegistry(hRootKey)) + { + fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]); + } + } + + if (reg_closeKey(hRootKey)) + { + fprintf(stderr, "closing root key of registry \"%s\" failed\n", argv[1]); + } + } else + { + fprintf(stderr, "open root key of registry \"%s\" failed\n", argv[1]); + } + + if (reg_closeRegistry(hReg)) + { + fprintf(stderr, "closing registry \"%s\" failed\n", argv[1]); + exit(1); + } + + return(0); +} + + diff --git a/registry/util/makefile.mk b/registry/util/makefile.mk new file mode 100644 index 000000000000..b9c9a7384a0d --- /dev/null +++ b/registry/util/makefile.mk @@ -0,0 +1,199 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=.. + +PRJNAME=registry +TARGET=reg + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +.INCLUDE : ..$/version.mk + +# ------------------------------------------------------------------ + +USE_LDUMP2=TRUE +#USE_DEFFILE=TRUE +LDUMP2=LDUMP3 + +DOCPPFILES= $(INC)$/registry$/registry.hxx \ + $(INC)$/registry$/registry.h \ + $(INC)$/registry$/regtype.h \ + $(INC)$/registry$/reflread.hxx \ + $(INC)$/registry$/reflwrit.hxx \ + $(INC)$/registry$/refltype.hxx \ + +LIB1TARGET= $(SLB)$/$(TARGET).lib + +LIB1FILES= $(SLB)$/$(TARGET)cpp.lib + +SHL1TARGET= $(REGISTRY_TARGET)$(REGISTRY_MAJOR) +SHL1IMPLIB= ireg +SHL1STDLIBS= \ + $(VOSLIB) \ + $(SALLIB) \ + $(STORELIB) \ + $(LIBCIMT) + + +SHL1LIBS=$(LIB1TARGET) +SHL1DEPN= $(LIB1TARGET) +SHL1DEF= $(MISC)$/$(SHL1TARGET).def +DEF1NAME =$(SHL1TARGET) + +DEF1DEPN =$(MISC)$/$(SHL1TARGET).flt + + +DEFLIB1NAME =$(TARGET) +DEF1DES =RegistryRuntime + +.IF "$(COM)"!="ICC" || "$(GUI)"=="OS2" +.IF "$(GUI)"!="MAC" +DEF1EXPORT1 =initRegistry_Api @1000 +DEF1EXPORT3 =initRegistryTypeWriter_Api @1001 +DEF1EXPORT4 =initRegistryTypeReader_Api @1002 +.ELSE +DEF1EXPORT1 =initRegistry_Api +DEF1EXPORT3 =initRegistryTypeWriter_Api +DEF1EXPORT4 =initRegistryTypeReader_Api +.ENDIF +.ELSE +DEF1EXPORT1 =_initRegistry_Api @1000 +DEF1EXPORT3 =_initRegistryTypeWriter_Api @1001 +DEF1EXPORT4 =_initRegistryTypeReader_Api @1002 +.ENDIF + +# --- Targets ------------------------------------------------------ + +.IF "$(GUI)"=="WIN" +ALL: $(LIB1TARGET) \ + $(MISC)$/implib.cmd + ALLTAR +.ENDIF + +.INCLUDE : target.mk + +makedocpp: $(DOCPPFILES) + + docpp -H -m -f -u -d $(OUT)$/doc$/$(PRJNAME) $(DOCPPFILES) + +# --- SO2-Filter-Datei --- + +$(MISC)$/$(SHL1TARGET).flt: makefile.mk + @echo ------------------------------ + @echo Making: $@ + @echo WEP > $@ + @echo LIBMAIN >> $@ + @echo LibMain >> $@ + @echo _Impl >> $@ + @echo ORegistry >> $@ + @echo ORegKey >> $@ + @echo ORegManager >> $@ + @echo CntStoreFile >> $@ + @echo CntStoreDirectory >> $@ + @echo CntStorePageLockBytes >> $@ + @echo initRegistry >> $@ + @echo _alloc >> $@ + @echo malloc >> $@ + @echo _lower_bound >> $@ + @echo _stl_prime >> $@ + @echo _stl_hash >> $@ + @echo _C >> $@ + @echo _TI2 >> $@ + @echo _TI3 >> $@ + @echo 1Reg >> $@ + @echo 1OGuard >> $@ + @echo _E >> $@ + @echo _H >> $@ + @echo _B >> $@ + @echo _I >> $@ + @echo next >> $@ + @echo HashString >> $@ + @echo distance >> $@ + @echo iterator >> $@ + @echo lower_bound >> $@ + @echo endl >> $@ + @echo flush >> $@ + @echo String >> $@ + @echo Const >> $@ + @echo read >> $@ + @echo write >> $@ + @echo Blop >> $@ + @echo parse >> $@ + @echo Version >> $@ + @echo Entry >> $@ + @echo Type >> $@ + @echo Field >> $@ + @echo magic >> $@ + @echo Pool >> $@ + @echo Method >> $@ + @echo 0CPI >> $@ + @echo exception::exception >> $@ + + + + + + diff --git a/registry/version.mk b/registry/version.mk new file mode 100644 index 000000000000..d97e6ecfec8e --- /dev/null +++ b/registry/version.mk @@ -0,0 +1,74 @@ +#************************************************************************* +# +# $RCSfile: version.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 15:18:42 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +# target +REGISTRY_TARGET=reg + +# the major +REGISTRY_MAJOR=2 +# the minor +REGISTRY_MINOR=0 +# the micro +REGISTRY_MICRO=0 + +# this is a c++ compatible library +REGISTRY_CPP=0 diff --git a/registry/workben/makefile.mk b/registry/workben/makefile.mk new file mode 100644 index 000000000000..edadeb34e988 --- /dev/null +++ b/registry/workben/makefile.mk @@ -0,0 +1,134 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=.. + +PRJNAME=registry +TARGET=regtest +TARGETTYPE=CUI +LIBTARGET=NO + +# --- Settings ----------------------------------------------------- +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files -------------------------------------------------------- +CDEFS += -DDLL_VERSION=\"$(UPD)$(DLLPOSTFIX)\" + +RGTLIB = rgt.lib +.IF "$(GUI)"=="UNX" +RGTLIB = -lrgt$(UPD)$(DLLPOSTFIX) +.ENDIF + + +CXXFILES= regtest.cxx \ + test.cxx \ + regspeed.cxx + + +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJ)$/regtest.obj + +APP1STDLIBS=\ + $(SALLIB) \ + $(REGLIB) + +.IF "$(GUI)"=="WNT" +APP1STDLIBS+= \ + $(LIBCIMT) $(LIBCMT) +.ENDIF + + +APP2TARGET= test +APP2OBJS= $(OBJ)$/test.obj + +APP2STDLIBS=\ + $(RGTLIB) + + +.IF "$(GUI)"=="WNT" +APP2STDLIBS+= \ + $(LIBCIMT) $(LIBCMT) +.ENDIF + + +APP3TARGET= regspeed +APP3OBJS= $(OBJ)$/regspeed.obj + +APP3STDLIBS=\ + $(SALLIB) \ + $(REGLIB) + +.IF "$(GUI)"=="WNT" +APP3STDLIBS+= \ + $(LIBCIMT) $(LIBCMT) +.ENDIF + + + +#.IF "$(COM)"=="ICC" +#ENVCFLAGS=$(ENVCFLAGS) -D_STD_NO_NAMESPACE -D_VOS_NO_NAMESPACE -D_UNO_NO_NAMESPACE +#.ENDIF + + +.INCLUDE : target.mk diff --git a/registry/workben/regspeed.cxx b/registry/workben/regspeed.cxx new file mode 100644 index 000000000000..dee8f61f9f15 --- /dev/null +++ b/registry/workben/regspeed.cxx @@ -0,0 +1,307 @@ +/************************************************************************* + * + * $RCSfile: regspeed.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <iostream.h> +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <sys/timeb.h> +#include <sys/types.h> + +#include "registry/registry.h" + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + + +/***************************************************************** + MyTimer +*****************************************************************/ +#ifndef UNX +class MyTimer +{ +public: + void start() { _ftime( &m_start ); }; + void stop() + { + _ftime( &m_stop ); + m_diff = difftime(m_stop.time, m_start.time); + if (m_stop.millitm > m_start.millitm) + { + m_diff += ((double)(m_stop.millitm - m_start.millitm)) / 1000; + } + else + { + m_diff -= 1; + m_diff += ((double)(1000 - (m_start.millitm - m_stop.millitm))) / 1000; + } + printf(" %.4f Sekunden\n", m_diff); + }; + +protected: +#ifdef OS2 + struct timeb m_start, m_stop; +#else + struct _timeb m_start, m_stop; +#endif + double m_diff; +}; +#else +extern "C" int ftime(struct timeb *pt); + +class MyTimer +{ +public: + void start() { ftime( &m_start ); }; + void stop() + { + ftime( &m_stop ); + m_diff = difftime(m_stop.time, m_start.time); + if (m_stop.millitm > m_start.millitm) + { + m_diff += ((double)(m_stop.millitm - m_start.millitm)) / 1000; + } + else + { + m_diff -= 1; + m_diff += ((double)(1000 - (m_start.millitm - m_stop.millitm))) / 1000; + } + printf(" %.4f Sekunden\n", m_diff); + }; + +protected: + struct timeb m_start, m_stop; + double m_diff; +}; +#endif + +using namespace rtl; + +#if (defined UNX) || (defined OS2) +int main( int argc, char * argv[] ) +#else +int _cdecl main( int argc, char * argv[] ) +#endif +{ + RegHandle hReg; + RegKeyHandle hRootKey, hKey, hSubKey, hSubSubKey; + OUString sName1(RTL_CONSTASCII_USTRINGPARAM("regkey")); + OUString sName2(RTL_CONSTASCII_USTRINGPARAM("regSubkey")); + OUString sName3(RTL_CONSTASCII_USTRINGPARAM("regSubSubkey")); + OUString keyName1; + OUString keyName2; + OUString keyName3; + int S1 = 10; + int S2 = 10; + int S3 = 10; + MyTimer aTimer; + + if (argc < 4) + { + cerr << "using regspeed count1 count2 count3\n"; + exit(1); + } + + S1 = atoi(argv[1]); + S2 = atoi(argv[2]); + S3 = atoi(argv[3]); + + OUString speedReg( RTL_CONSTASCII_USTRINGPARAM("speed.reg")); + if (reg_createRegistry(speedReg.pData, &hReg)) + { + cout << "creating registry \"test.reg\" failed\n"; + } else + { + if (reg_openRootKey(hReg, &hRootKey)) + { + cout << "open root key \"test.reg\" failed\n"; + } else + { + printf("\n %d keys anlegen, oeffnen und schliessen dauert ... ", (S1 * S2 * S3)); + aTimer.start(); + + for (sal_Int32 i=0; i < S1; i++) + { + keyName1 = sName1; + keyName1 += OUString().valueOf(i); + if (reg_createKey(hRootKey, keyName1.pData, &hKey)) + cout << "creating key \"" << OUStringToOString(keyName1, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + + for (sal_Int32 j=0; j < S2; j++) + { + keyName2 = sName2; + keyName2 += OUString().valueOf(j); + if (reg_createKey(hKey, keyName2.pData, &hSubKey)) + cout << "creating key \"" << OUStringToOString(keyName2, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + + for (sal_Int32 n=0; n < S3; n++) + { + keyName3 = sName3; + keyName3 += OUString().valueOf(n); + if (reg_createKey(hSubKey, keyName3.pData, &hSubSubKey)) + cout << "creating key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + + if (reg_closeKey(hSubSubKey)) + cout << "closing key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + } + + if (reg_closeKey(hSubKey)) + cout << "closing key \"" << OUStringToOString(keyName2, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + } + + if (reg_closeKey(hKey)) + cout << "closing key \"" << OUStringToOString(keyName1, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + } + + aTimer.stop(); + + printf("\n %d keys oeffnen und schliessen dauert ... ", (S1 * S2 * S3)); + aTimer.start(); + + for (i=0; i < S1; i++) + { + keyName1 = OUString::createFromAscii("/"); + keyName1 += sName1; + keyName1 += OUString().valueOf(i); + if (reg_openKey(hRootKey, keyName1.pData, &hKey)) + cout << "open key \"" << OUStringToOString(keyName1, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + + for (sal_Int32 j=0; j < S2; j++) + { + keyName2 = OUString::createFromAscii("/"); + keyName2 += sName1; + keyName2 += OUString().valueOf(i); + keyName2 += OUString::createFromAscii("/"); + keyName2 += sName2; + keyName2 += OUString().valueOf(j); + if (reg_openKey(hRootKey, keyName2.pData, &hSubKey)) + cout << "open key \"" << OUStringToOString(keyName2, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + + for (sal_Int32 n=0; n < S3; n++) + { + keyName3 = OUString::createFromAscii("/"); + keyName3 += sName1; + keyName3 += OUString().valueOf(i); + keyName3 += OUString::createFromAscii("/"); + keyName3 += sName2; + keyName3 += OUString().valueOf(j); + keyName3 += OUString::createFromAscii("/"); + keyName3 += sName3; + keyName3 += OUString().valueOf(n); + if (reg_openKey(hRootKey, keyName3.pData, &hSubSubKey)) + cout << "open key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + + if (reg_closeKey(hSubSubKey)) + cout << "open key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + } + + if (reg_closeKey(hSubKey)) + cout << "closing key \"" << OUStringToOString(keyName2, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + } + + if (reg_closeKey(hKey)) + cout << "closing key \"" << OUStringToOString(keyName1, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + } + + aTimer.stop(); + + printf("\n 1 key oeffnen und schliessen dauert ... "); + aTimer.start(); + + if (reg_openKey(hRootKey, keyName3.pData, &hSubSubKey)) + cout << "open key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + + if (reg_closeKey(hSubSubKey)) + cout << "open key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr() + << "\" failed\n"; + + aTimer.stop(); + + } + + if (reg_closeKey(hRootKey)) + cout << "closing root key failed\n"; + if (reg_closeRegistry(hReg)) + cout << "\t41. closing registry \"test.reg\" failed\n"; + } + + return(0); +} + + diff --git a/registry/workben/regtest.cxx b/registry/workben/regtest.cxx new file mode 100644 index 000000000000..a39f34fe2c80 --- /dev/null +++ b/registry/workben/regtest.cxx @@ -0,0 +1,376 @@ +/************************************************************************* + * + * $RCSfile: regtest.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <iostream.h> +#include <stdio.h> + +#include "registry/registry.h" + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + +using namespace rtl; + +#if (defined UNX) || (defined OS2) +int main( int argc, char * argv[] ) +#else +int _cdecl main( int argc, char * argv[] ) +#endif +{ + RegHandle hReg; + RegKeyHandle hRootKey, hKey1, hKey2, hKey3, hKey4, hKey5; + + cout << "\n Simple Registry Test !!! \n\n"; + + if (reg_createRegistry(OUString::createFromAscii("test4.rdb").pData, &hReg)) + cout << "\t0. creating registry \"test4.rdb\" failed\n"; + else + cout << "0. registry test4.rdb is created\n"; + + if (reg_openRootKey(hReg, &hRootKey)) + cout << "1. open root key \"test4.rdb\" failed\n"; + else + cout << "1. root key of \"test4.rdb\" is opened\n"; + + if (reg_createKey(hRootKey, OUString::createFromAscii("myFirstKey").pData, &hKey1)) + cout << "\t2. creating key \"myFirstKey\" failed\n"; + else + cout << "2. key \"myFirstKey\" is created\n"; + if (reg_createKey(hRootKey, OUString::createFromAscii("mySecondKey").pData, &hKey2)) + cout << "\t3. creating key \"mySecondKey\" failed\n"; + else + cout << "3. key \"mySecondKey\" is created\n"; + if (reg_createKey(hKey1, OUString::createFromAscii("myFirstSubKey").pData, &hKey3)) + cout << "\t4. creating subkey \"myFirstSubKey\" failed\n"; + else + cout << "4. subkey \"myFirstSubKey\" is created\n"; + if (reg_createKey(hKey1, OUString::createFromAscii("mySecondSubKey").pData, &hKey4)) + cout << "\t5. creating subkey \"mySecondSubKey\" failed\n"; + else + cout << "5. subkey \"mySecondSubKey\" is created\n"; + if (reg_createKey(hRootKey, OUString::createFromAscii("myThirdKey").pData, &hKey5)) + cout << "\t6. creating key \"myThirdKey\" is created\n\n"; + else + cout << "6. key \"myThirdKey\" is created\n\n"; + + + RegKeyHandle* phSubKeys; + sal_uInt32 nSubKeys; + if (reg_openSubKeys(hRootKey, OUString::createFromAscii("myFirstKey").pData, &phSubKeys, &nSubKeys)) + cout << "\t7. open subkeys of \"myfirstKey\" failed\n"; + else + cout << "7. open " << nSubKeys << "subkeys of \"myfirstKey\"\n"; + + OUString keyName; + if (reg_getKeyName(phSubKeys[0], &keyName.pData)) + cout << "\tname of subkey 1 = " << OUStringToOString(keyName, RTL_TEXTENCODING_ASCII_US).getStr() << "\n"; + if (reg_getKeyName(phSubKeys[1], &keyName.pData)) + cout << "\tname of subkey 2 = " << OUStringToOString(keyName, RTL_TEXTENCODING_ASCII_US).getStr() << "\n"; + + if (reg_closeSubKeys(phSubKeys, nSubKeys)) + cout << "\t8. close subkeys of \"myfirstKey\" failed\n\n"; + else + cout << "8. close " << nSubKeys << "subkeys of \"myfirstKey\"\n\n"; + + + char* Value="Mein erster Value"; + if (reg_setValue(hRootKey, OUString::createFromAscii("mySecondKey").pData, RG_VALUETYPE_STRING, Value, 18)) + cout << "\t9. setValue of key \"mySecondKey\" failed\n"; + else + cout << "9. setValue (string Value) of key \"mySecondKey\"\n"; + + RegValueType valueType; + sal_uInt32 valueSize; + sal_Char* readValue; + if (reg_getValueInfo(hRootKey, OUString::createFromAscii("mySecondKey").pData, &valueType, &valueSize)) + cout << "\t10. getValueInfo of key \"mySecondKey\" failed\n"; + else + cout << "10. getValueInfo of key \"mySecondKey\"\n"; + + readValue = (sal_Char*)rtl_allocateMemory(valueSize); + if (reg_getValue(hKey2, OUString().pData, readValue)) + cout << "\t11. getValue of key \"mySecondKey\" failed\n"; + else + { + cout << "11. getValue of key \"mySecondKey\"\n"; + + cout << "read Value,\n\tvalueType = " << (long)valueType + << "\n\tvalueSize = " << valueSize + << "\n\tvalue = " << readValue << "\n\n"; + } + rtl_freeMemory(readValue); + + if (reg_closeKey(hKey1) || + reg_closeKey(hKey3) || + reg_closeKey(hKey4)) + cout << "\t12. closing \"myFirstKey\" \"myfistSubKey\" \"mySecondSubKey\" failed\n"; + else + cout << "12. keys \"myFirstKey\" \"myfistSubKey\" \"mySecondSubKey\" are closed\n"; + + if (reg_deleteKey(hRootKey, OUString::createFromAscii("myFirstKey").pData)) + cout << "13.\t delete key \"myFirstKey\" failed\n"; + else + cout << "13. key \"myFirstKey\" is deleted\n"; + + if (reg_closeKey(hKey2)) + cout << "\t14. closing key \"mySecondKey\" failed\n"; + else + cout << "14. key \"mySecondKey\" is closed\n"; + + if (reg_openKey(hRootKey, OUString::createFromAscii("mySecondKey").pData, &hKey2)) + cout << "\n15. open key \"mySecondKey\" failed\n"; + else + cout << "15. key \"mySecondKey\" is opended\n"; + + if (reg_closeKey(hKey5)) + cout << "\t15. closing key \"myThirdSubKey\" failed\n"; + else + cout << "15. key \"myThirdSubKey\" is closed\n"; + if (reg_deleteKey(hRootKey, OUString::createFromAscii("myThirdKey").pData)) + cout << "\t16. delete key \"myThirdKey\" failed\n"; + else + cout << "16. key \"myThirdKey\" is deleted\n"; + + if (reg_openKey(hRootKey, OUString::createFromAscii("myThirdKey").pData, &hKey5)) + cout << "\t17. open key \"myThirdKey\" failed\n"; + else + cout << "17. key \"myThirdKey\" is opened\n"; + + cout << "\n close open keys\n\n"; + + if (reg_closeKey(hKey2)) + cout << "\t18. closing key \"mySecondKey\" failed\n"; + else + cout << "18. key \"mySecondKey\" is closed\n"; + + if (reg_closeKey(hRootKey)) + cout << "\t19. closing root key failed\n"; + else + cout << "19. root key is closed\n"; + + if (reg_closeRegistry(hReg)) + cout << "\t20. closing registry \"test4.rdb\" failed\n"; + else + cout << "20. registry \"test4.rdb\" is closed\n"; + + // Test loadkey + cout << "\nTest load key\n\n"; + + RegHandle hReg2; + RegKeyHandle hRootKey2, h2Key1, h2Key2, h2Key3, h2Key4, h2Key5; + + if (reg_createRegistry(OUString::createFromAscii("test5.rdb").pData, &hReg2)) + cout << "\t21. creating registry \"test5.rdb\" failed\n"; + else + cout << "21. registry \"test5.rdb\" is created\n"; + + if (reg_openRootKey(hReg2, &hRootKey2)) + cout << "\t22. open root key of \"test5.rdb\" failed\n"; + else + cout << "22. root key of \"test5.rdb\" is opened\n"; + + if (reg_createKey(hRootKey2, OUString::createFromAscii("reg2FirstKey").pData, &h2Key1)) + cout << "\t23. creating key \"reg2FirstKey\" failed\n"; + else + cout << "23. key \"reg2FirstKey\" is created\n"; + if (reg_createKey(hRootKey2, OUString::createFromAscii("reg2SecondKey").pData, &h2Key2)) + cout << "\t24. creating key \"reg2SecondKey\" failed\n"; + else + cout << "24. key \"reg2SecondKey\" is created\n"; + if (reg_createKey(h2Key1, OUString::createFromAscii("reg2FirstSubKey").pData, &h2Key3)) + cout << "\t25. creating key \"reg2FirstSubKey\" failed\n"; + else + cout << "25. key \"reg2FirstSubKey\" is created\n"; + if (reg_createKey(h2Key1, OUString::createFromAscii("reg2SecondSubKey").pData, &h2Key4)) + cout << "\26. creating key \"reg2SecondSubKey\" failed\n"; + else + cout << "26. key \"reg2SecondSubKey\" is created\n"; + if (reg_createKey(hRootKey2, OUString::createFromAscii("reg2ThirdKey").pData, &h2Key5)) + cout << "\n27. creating key \"reg2ThirdKey\" failed\n"; + else + cout << "27. key \"reg2ThirdKey\" is created\n"; + + sal_uInt32 nValue= 123456789; + if (reg_setValue(h2Key3, OUString().pData, RG_VALUETYPE_LONG, &nValue, sizeof(sal_uInt32))) + cout << "\t27.b) setValue of key \"reg2FirstSubKey\" failed\n"; + else + cout << "27.b). setValue (long Value) of key \"reg2FirstSubKey\"\n"; + + if (reg_closeKey(h2Key1) || + reg_closeKey(h2Key2) || + reg_closeKey(h2Key3) || + reg_closeKey(h2Key4) || + reg_closeKey(h2Key5)) + cout << "\n\t28. closing keys of \"test5.rdb\" failed\n"; + else + cout << "\n28. all keys of \"test5.rdb\" closed\n"; + + if (reg_closeKey(hRootKey2)) + cout << "\t29. root key of \"test5.rdb\" failed\n"; + else + cout << "29. root key of \"test5.rdb\" is closed\n"; + + if (reg_closeRegistry(hReg2)) + cout << "\t30. registry test5.rdb is closed\n"; + else + cout << "30. registry test5.rdb is closed\n"; + + if (reg_openRegistry(OUString::createFromAscii("test4.rdb").pData, &hReg, REG_READWRITE)) + cout << "\t31. registry test4.rdb is opened\n"; + else + cout << "31. registry test4.rdb is opened\n"; + + if (reg_openRootKey(hReg, &hRootKey)) + cout << "\t32. open root key of \"test4.rdb\" is failed\n"; + else + cout << "32. root key of \"test4.rdb\" is opened\n"; + + if (reg_loadKey(hRootKey, OUString::createFromAscii("allFromTest2").pData, + OUString::createFromAscii("test5.rdb").pData)) + cout << "\n\t33. load all keys from \"test5.rdb\" under key \"allFromTest2\" failed\n"; + else + cout << "\n33. load all keys from test5.rdb under key \"allFromTest2\"\n"; + + if (reg_saveKey(hRootKey, OUString::createFromAscii("allFromTest2").pData, + OUString::createFromAscii("test6.rdb").pData)) + cout << "\n\t34. save all keys under \"allFromTest2\" in test6.rdb\n"; + else + cout << "\n34. save all keys under \"allFromTest2\" in test6.rdb\n"; + + + if (reg_createKey(hRootKey, OUString::createFromAscii("allFromTest3").pData, &hKey1)) + cout << "\t35. creating key \"allFromTest3\" failed\n"; + else + cout << "36. key \"allFromTest3\" is created\n"; + if (reg_createKey(hKey1, OUString::createFromAscii("myFirstKey2").pData, &hKey2)) + cout << "\t37. creating key \"myFirstKey2\" failed\n"; + else + cout << "37. key \"myFirstKey2\" is created\n"; + if (reg_createKey(hKey1, OUString::createFromAscii("mySecondKey2").pData, &hKey3)) + cout << "\t38. creating key \"mySecondKey2\" failed\n"; + else + cout << "38. key \"mySecondKey2\" is created\n"; + + if (reg_mergeKey(hRootKey, OUString::createFromAscii("allFromTest3").pData, + OUString::createFromAscii("test6.rdb").pData, sal_False, sal_False)) + cout << "\n\t39. merge all keys under \"allFromTest2\" with all in test6.rdb\n"; + else + cout << "\n39. merge all keys under \"allFromTest2\" with all in test6.rdb\n"; + + if (reg_closeKey(hKey1)) + cout << "\n\t40. closing key \"allFromTest3\" of \"test5.rdb\" failed\n"; + else + cout << "\n40. closing key \"allFromTest3\" of \"test5.rdb\"\n"; + if (reg_closeKey(hKey2)) + cout << "\n\t41. closing key \"myFirstKey2\" of \"test5.rdb\" failed\n"; + else + cout << "\n41. closing key \"myFirstKey2\" of \"test5.rdb\"\n"; + if (reg_closeKey(hKey3)) + cout << "\n\t42. closing key \"mySecondKey2\" of \"test5.rdb\" failed\n"; + else + cout << "\n42. closing key \"mySecondKey2\" of \"test5.rdb\"\n"; + + + if (reg_deleteKey(hRootKey, OUString::createFromAscii("/allFromTest3/reg2FirstKey/reg2FirstSubKey").pData)) + cout << "\n\t43. delete key \"/allFromTest3/reg2FirstKey/reg2FirstSubKey\" failed\n"; + else + cout << "\n43. key \"/allFromTest3/reg2FirstKey/reg2FirstSubKey\" is deleted\n"; + + if (reg_openRegistry(OUString::createFromAscii("test4.rdb").pData, &hReg2, REG_READONLY)) + cout << "\n\t44. registry test4.rdb is opened for read only\n"; + else + cout << "\n44. registry test4.rdb is opened for read only\n"; + + RegHandle hReg3; + if (reg_openRegistry(OUString::createFromAscii("test4.rdb").pData, &hReg3, REG_READONLY)) + cout << "\n\t44.a). registry test4.rdb is opened for read only\n"; + else + cout << "\n44.a). registry test4.rdb is opened for read only\n"; + + if (reg_closeRegistry(hReg2)) + cout << "\t45. closing registry \"test4.rdb\" failed\n"; + else + cout << "45. registry \"test4.rdb\" is closed\n"; + + if (reg_closeKey(hRootKey)) + cout << "\n\t46. closing root key of \"test4.rdb\" failed\n"; + else + cout << "\n46. root key of \"test4.rdb\" is closed\n"; + + if (reg_closeRegistry(hReg)) + cout << "\t47. closing registry \"test4.rdb\" failed\n"; + else + cout << "47. registry \"test4.rdb\" is closed\n"; + + if (reg_closeRegistry(hReg3)) + cout << "\t47.a). closing registry \"test4.rdb\" failed\n"; + else + cout << "47.a). registry \"test4.rdb\" is closed\n"; + + return(0); +} + + diff --git a/registry/workben/test.cxx b/registry/workben/test.cxx new file mode 100644 index 000000000000..2ba0c6661750 --- /dev/null +++ b/registry/workben/test.cxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * $RCSfile: test.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <stdio.h> + +#if (defined UNX) || (defined OS2) +int main( int argc, char * argv[] ) +#else +int _cdecl main( int argc, char * argv[] ) +#endif +{ + void test_coreReflection(); + void test_registry_CppApi(); + void test_generateMerge1(); + void test_generateMerge2(); + void test_merge(); + + test_coreReflection(); + test_registry_CppApi(); + test_generateMerge1(); + test_generateMerge2(); + test_merge(); + + return(0); +} + + |