1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <salhelper/dynload.hxx>
21 #include <rtl/ustrbuf.hxx>
26 typedef void* (SAL_CALL
*ApiInitFunction
) (void);
28 ORealDynamicLoader::ORealDynamicLoader(ORealDynamicLoader
** ppSetToZeroInDestructor_
,
29 const rtl::OUString
& moduleName
,
30 const rtl::OUString
& initFunction
,
36 , m_strModuleName(moduleName
)
37 , m_strInitFunction(initFunction
)
38 , ppSetToZeroInDestructor( ppSetToZeroInDestructor_
)
42 ORealDynamicLoader
* ORealDynamicLoader::newInstance(ORealDynamicLoader
** ppSetToZeroInDestructor
,
43 const rtl::OUString
& moduleName
,
44 const rtl::OUString
& initFunction
)
46 #ifdef DISABLE_DYNLOADING
47 (void) ppSetToZeroInDestructor
;
53 ApiInitFunction initFunc
;
54 oslModule pModule
= osl_loadModule(moduleName
.pData
, SAL_LOADMODULE_DEFAULT
);
61 initFunc
= (ApiInitFunction
)osl_getFunctionSymbol(
62 pModule
, initFunction
.pData
);
66 osl_unloadModule(pModule
);
70 return(new ORealDynamicLoader(ppSetToZeroInDestructor
, moduleName
,
77 ORealDynamicLoader::~ORealDynamicLoader()
79 // set the address to zero
80 if( ppSetToZeroInDestructor
)
81 *ppSetToZeroInDestructor
= 0;
85 #ifndef DISABLE_DYNLOADING
86 osl_unloadModule(m_pModule
);
92 sal_uInt32
ORealDynamicLoader::acquire()
97 sal_uInt32
ORealDynamicLoader::release()
99 sal_uInt32 nRet
= --m_refCount
;
106 void* ORealDynamicLoader::getApi() const
111 } // namespace salhelper
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */