diff options
author | Juergen Schmidt <jsc@openoffice.org> | 2001-03-16 12:25:09 +0000 |
---|---|---|
committer | Juergen Schmidt <jsc@openoffice.org> | 2001-03-16 12:25:09 +0000 |
commit | cb08bfdd90f6ef8c783fbe8117c92244137abbf9 (patch) | |
tree | 016ab073ffe20f07b5f7602191b0d51c2b60ea62 /salhelper | |
parent | 4fd04b6224b240bc8b890f4d25d71442108fb1c1 (diff) |
new
Diffstat (limited to 'salhelper')
-rw-r--r-- | salhelper/inc/salhelper/dynload.hxx | 193 | ||||
-rw-r--r-- | salhelper/prj/build.lst | 3 | ||||
-rw-r--r-- | salhelper/prj/d.lst | 14 | ||||
-rw-r--r-- | salhelper/source/dynload.cxx | 148 | ||||
-rw-r--r-- | salhelper/source/makefile.mk | 115 | ||||
-rw-r--r-- | salhelper/source/staticmb.cxx | 60 | ||||
-rw-r--r-- | salhelper/version.mk | 79 |
7 files changed, 612 insertions, 0 deletions
diff --git a/salhelper/inc/salhelper/dynload.hxx b/salhelper/inc/salhelper/dynload.hxx new file mode 100644 index 000000000000..b839d6e15805 --- /dev/null +++ b/salhelper/inc/salhelper/dynload.hxx @@ -0,0 +1,193 @@ +/************************************************************************* + * + * $RCSfile: dynload.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: jsc $ $Date: 2001-03-16 13:21:44 $ + * + * 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 _SALHELPER_DYNLOAD_HXX_ +#define _SALHELPER_DYNLOAD_HXX_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#ifndef _OSL_MODULE_H_ +#include <osl/module.h> +#endif + +namespace salhelper +{ + +class ORealDynamicLoader +{ +public: + + SAL_DLLEXPORT static ORealDynamicLoader* SAL_CALL newInstance( + ORealDynamicLoader ** ppSetToZeroInDestructor, + const ::rtl::OUString& strModuleName, + const ::rtl::OUString& strInitFunction ); + + sal_uInt32 SAL_CALL acquire(); + sal_uInt32 SAL_CALL release(); + + void* SAL_CALL getApi() const; + +protected: + ORealDynamicLoader( ORealDynamicLoader ** ppSetToZeroInDestructor, + const ::rtl::OUString& strModuleName, + const ::rtl::OUString& strInitFunction, + void* pApi, + oslModule pModule ); + + virtual ~ORealDynamicLoader(); + + void* m_pApi; + sal_uInt32 m_refCount; + oslModule m_pModule; + ::rtl::OUString m_strModuleName; + ::rtl::OUString m_strInitFunction; + ORealDynamicLoader ** ppSetToZeroInDestructor; +}; + +template<class API> +class ODynamicLoader //: public OObject +{ +public: + ODynamicLoader() SAL_THROW(()) + { + m_pLoader = 0; + } + + ODynamicLoader( const ::rtl::OUString& strModuleName, + const ::rtl::OUString& strInitFunction ) SAL_THROW(()) + { + if (!m_pStaticLoader) + { + m_pStaticLoader = ORealDynamicLoader::newInstance( + &m_pStaticLoader, + strModuleName, + strInitFunction); + } + else + { + m_pStaticLoader->acquire(); + } + + m_pLoader = m_pStaticLoader; + } + + + ODynamicLoader(const ODynamicLoader<API>& toCopy) SAL_THROW(()) + { + m_pLoader = toCopy.m_pLoader; + if( m_pLoader ) + m_pLoader->acquire(); + } + + ~ODynamicLoader() SAL_THROW(()) + { + if( m_pLoader ) + m_pLoader->release(); + } + + ODynamicLoader<API>& SAL_CALL operator = (const ODynamicLoader<API>& toAssign) SAL_THROW(()) + { + if( m_pLoader != toAssign.m_pLoader ) + { + if( toAssign.m_pLoader ) + toAssign.m_pLoader->acquire(); + if( m_pLoader ) + m_pLoader->release(); + m_pLoader = toAssign.m_pLoader; + } + + return (*this); + } + + API* SAL_CALL getApi() const SAL_THROW(()) + { + return (API*)m_pLoader->getApi(); + } + + API* SAL_CALL operator->() const SAL_THROW(()) + { + return (API*)m_pLoader->getApi(); + } + + sal_Bool SAL_CALL isLoaded() const SAL_THROW(()) + { + return (m_pLoader != NULL); + } + +protected: + static ORealDynamicLoader* m_pStaticLoader; + ORealDynamicLoader* m_pLoader; +}; + + +template<class API> +ORealDynamicLoader* ODynamicLoader<API>::m_pStaticLoader = NULL; + +} + +#endif + diff --git a/salhelper/prj/build.lst b/salhelper/prj/build.lst new file mode 100644 index 000000000000..9a21849507ff --- /dev/null +++ b/salhelper/prj/build.lst @@ -0,0 +1,3 @@ +shp salhelper : sal NULL +shp salhelper usr1 - all shp_mkout NULL +shp salhelper\source nmake - all shp_source NULL diff --git a/salhelper/prj/d.lst b/salhelper/prj/d.lst new file mode 100644 index 000000000000..7701aeeb6a4a --- /dev/null +++ b/salhelper/prj/d.lst @@ -0,0 +1,14 @@ +mkdir: %_DEST%\inc%_EXT%\salhelper + +..\inc\salhelper\dynload.hxx %_DEST%\inc%_EXT%\salhelper\dynload.hxx + + +..\%__SRC%\bin\salhelper*.dll %_DEST%\bin%_EXT%\salhelper*.dll +..\%__SRC%\lib\*salhelper*.lib %_DEST%\lib%_EXT%\* + +..\%__SRC%\lib\libsalhelper*.so %_DEST%\lib%_EXT%\* +..\%__SRC%\lib\libsalhelper*.dylib %_DEST%\lib%_EXT%\* +..\%__SRC%\lib\libsalhelper*.a %_DEST%\lib%_EXT%\* +..\%__SRC%\lib\salhelper*.lib %_DEST%\lib%_EXT%\* +..\%__SRC%\misc\salhelper*.pdb %_DEST%\misc%_EXT%\* +..\version.mk %_DEST%\inc%_EXT%\salhelper\version.mk diff --git a/salhelper/source/dynload.cxx b/salhelper/source/dynload.cxx new file mode 100644 index 000000000000..e35aa518b0d8 --- /dev/null +++ b/salhelper/source/dynload.cxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * $RCSfile: dynload.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: jsc $ $Date: 2001-03-16 13:23:40 $ + * + * 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 _SALHELPER_DYNLOAD_HXX_ +#include <salhelper/dynload.hxx> +#endif + +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +namespace salhelper +{ + +typedef void* (SAL_CALL *ApiInitFunction) (void); + +ORealDynamicLoader::ORealDynamicLoader(ORealDynamicLoader ** ppSetToZeroInDestructor_, + const rtl::OUString& moduleName, + const rtl::OUString& initFunction, + void* pApi, + oslModule pModule) + : m_pApi(pApi) + , m_refCount(1) + , m_pModule(pModule) + , m_strModuleName(moduleName) + , m_strInitFunction(initFunction) + , ppSetToZeroInDestructor( ppSetToZeroInDestructor_ ) +{ +} + +SAL_DLLEXPORT ORealDynamicLoader* ORealDynamicLoader::newInstance(ORealDynamicLoader ** ppSetToZeroInDestructor, + const rtl::OUString& moduleName, + const rtl::OUString& initFunction) +{ + ApiInitFunction initFunc; + oslModule pModule = osl_loadModule(moduleName.pData, SAL_LOADMODULE_DEFAULT); + + if ( !pModule ) + { + return NULL; + } + + initFunc = (ApiInitFunction)osl_getSymbol(pModule, initFunction.pData); + + if ( !initFunc ) + { + osl_unloadModule(pModule); + return NULL; + } + + return(new ORealDynamicLoader(ppSetToZeroInDestructor, moduleName, + initFunction, + initFunc(), + pModule)); +} + +ORealDynamicLoader::~ORealDynamicLoader() +{ + // set the address to zero + if( ppSetToZeroInDestructor ) + *ppSetToZeroInDestructor = 0; + + if (m_pModule) + { + osl_unloadModule(m_pModule); + m_pModule = NULL; + } +} + +sal_uInt32 ORealDynamicLoader::acquire() +{ + return ++m_refCount; +} + +sal_uInt32 ORealDynamicLoader::release() +{ + sal_uInt32 nRet = --m_refCount; + if( nRet == 0 ) + delete this; + return nRet; +} + + +void* ORealDynamicLoader::getApi() const +{ + return m_pApi; +} + +} // namespace salhelper + diff --git a/salhelper/source/makefile.mk b/salhelper/source/makefile.mk new file mode 100644 index 000000000000..28ed51987199 --- /dev/null +++ b/salhelper/source/makefile.mk @@ -0,0 +1,115 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: jsc $ $Date: 2001-03-16 13:23:40 $ +# +# 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= salhelper +TARGET= salhelper +NO_BSYMBOLIC= TRUE +ENABLE_EXCEPTIONS=TRUE + +USE_DEFFILE= TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +.INCLUDE : ..$/version.mk + +# --- Files -------------------------------------------------------- + + +# LIB1TARGET= $(LB)$/a$(TARGET).lib +# LIB1ARCHIV= $(LB)$/lib$(TARGET)$(SALHELPER_MAJOR)$(COM).a +# LIB1FILES= $(LB)$/$(TARGET).lib + +SLOFILES= \ + $(SLO)$/dynload.obj + +# SCO and MACOSX: the linker does know about weak symbols, but we can't ignore multiple defined symbols +.IF "$(OS)"=="SCO" || "$(OS)$(COM)"=="OS2GCC" || "$(OS)"=="MACOSX" +SLOFILES+=$(SLO)$/staticmb.obj +#OBJFILES+=$(OBJ)$/staticmb.obj +.ENDIF + +SHL1TARGET= $(TARGET)$(CPPUHELPER_MAJOR)$(COM) + +SHL1STDLIBS= \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt +DEFLIB1NAME= $(TARGET) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +$(MISC)$/$(SHL1TARGET).flt : makefile.mk + +echo _TI2 >$@ + +echo _TI1 >>$@ diff --git a/salhelper/source/staticmb.cxx b/salhelper/source/staticmb.cxx new file mode 100644 index 000000000000..2cc81294f9c5 --- /dev/null +++ b/salhelper/source/staticmb.cxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * $RCSfile: staticmb.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: jsc $ $Date: 2001-03-16 13:23:40 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ diff --git a/salhelper/version.mk b/salhelper/version.mk new file mode 100644 index 000000000000..48bb59d9713e --- /dev/null +++ b/salhelper/version.mk @@ -0,0 +1,79 @@ +#************************************************************************* +# +# $RCSfile: version.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: jsc $ $Date: 2001-03-16 13:25:09 $ +# +# 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 +SALHELPER_TARGET=salhelper + +# the major +SALHELPER_MAJOR=2 +# the minor +SALHELPER_MINOR=0 +# the micro +SALHELPER_MICRO=0 + +# this is a c++ compatible library +SALHELPER_CPP=1 + +SALHELPER=$(SALHELPER_TARGET)_$(CMPEXT) + +LIBSALHELPER_UNX=lib$(SALHELPER).a.$(SALHELPER_MAJOR) +LIBSALHELPER_WIN=$(SALHELPER_TARGET)$(SALHELPER_MAJOR)$(CMPEXT).dll |