LCOV - code coverage report
Current view: top level - salhelper/source - dynload.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 28 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <salhelper/dynload.hxx>
      21             : #include <rtl/ustrbuf.hxx>
      22             : 
      23             : namespace salhelper
      24             : {
      25             : 
      26             : typedef void*   (SAL_CALL *ApiInitFunction) (void);
      27             : 
      28           0 : ORealDynamicLoader::ORealDynamicLoader(ORealDynamicLoader ** ppSetToZeroInDestructor_,
      29             :                        const rtl::OUString& moduleName,
      30             :                        const rtl::OUString& initFunction,
      31             :                        void* pApi,
      32             :                        oslModule pModule)
      33             :     : m_pApi(pApi)
      34             :     , m_refCount(1)
      35             :     , m_pModule(pModule)
      36             :     , m_strModuleName(moduleName)
      37             :     , m_strInitFunction(initFunction)
      38           0 :     , ppSetToZeroInDestructor( ppSetToZeroInDestructor_ )
      39             : {
      40           0 : }
      41             : 
      42           0 : ORealDynamicLoader* ORealDynamicLoader::newInstance(ORealDynamicLoader ** ppSetToZeroInDestructor,
      43             :                                   const rtl::OUString& moduleName,
      44             :                                   const rtl::OUString& initFunction)
      45             : {
      46             : #ifdef DISABLE_DYNLOADING
      47             :     (void) ppSetToZeroInDestructor;
      48             :     (void) moduleName;
      49             :     (void) initFunction;
      50             : 
      51             :     return NULL;
      52             : #else
      53             :     ApiInitFunction initFunc;
      54           0 :     oslModule pModule = osl_loadModule(moduleName.pData, SAL_LOADMODULE_DEFAULT);
      55             : 
      56           0 :     if ( !pModule )
      57             :     {
      58           0 :         return NULL;
      59             :     }
      60             : 
      61             :     initFunc = reinterpret_cast<ApiInitFunction>(osl_getFunctionSymbol(
      62           0 :         pModule, initFunction.pData));
      63             : 
      64           0 :     if ( !initFunc )
      65             :     {
      66           0 :         osl_unloadModule(pModule);
      67           0 :         return NULL;
      68             :     }
      69             : 
      70             :     return(new ORealDynamicLoader(ppSetToZeroInDestructor, moduleName,
      71             :                                  initFunction,
      72             :                                  initFunc(),
      73           0 :                                  pModule));
      74             : #endif
      75             : }
      76             : 
      77           0 : ORealDynamicLoader::~ORealDynamicLoader()
      78             : {
      79             :     // set the address to zero
      80           0 :     if( ppSetToZeroInDestructor )
      81           0 :         *ppSetToZeroInDestructor = 0;
      82             : 
      83           0 :     if (m_pModule)
      84             :     {
      85             : #ifndef DISABLE_DYNLOADING
      86           0 :         osl_unloadModule(m_pModule);
      87             : #endif
      88           0 :         m_pModule = NULL;
      89             :     }
      90           0 : }
      91             : 
      92           0 : sal_uInt32 ORealDynamicLoader::acquire()
      93             : {
      94           0 :     return ++m_refCount;
      95             : }
      96             : 
      97           0 : sal_uInt32 ORealDynamicLoader::release()
      98             : {
      99           0 :     sal_uInt32 nRet = --m_refCount;
     100           0 :     if( nRet == 0 )
     101           0 :         delete this;
     102           0 :     return nRet;
     103             : }
     104             : 
     105             : 
     106           0 : void* ORealDynamicLoader::getApi() const
     107             : {
     108           0 :     return m_pApi;
     109             : }
     110             : 
     111             : } // namespace salhelper
     112             : 
     113             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11