LCOV - code coverage report
Current view: top level - salhelper/source - dynload.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 28 0.0 %
Date: 2012-08-25 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 18 0.0 %

           Branch data     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                 :            :     ApiInitFunction initFunc;
      47                 :          0 :     oslModule pModule = osl_loadModule(moduleName.pData, SAL_LOADMODULE_DEFAULT);
      48                 :            : 
      49         [ #  # ]:          0 :     if ( !pModule )
      50                 :            :     {
      51                 :          0 :         return NULL;
      52                 :            :     }
      53                 :            : 
      54                 :            :     initFunc = (ApiInitFunction)osl_getFunctionSymbol(
      55                 :          0 :         pModule, initFunction.pData);
      56                 :            : 
      57         [ #  # ]:          0 :     if ( !initFunc )
      58                 :            :     {
      59                 :          0 :         osl_unloadModule(pModule);
      60                 :          0 :         return NULL;
      61                 :            :     }
      62                 :            : 
      63                 :            :     return(new ORealDynamicLoader(ppSetToZeroInDestructor, moduleName,
      64                 :            :                                  initFunction,
      65                 :            :                                  initFunc(),
      66         [ #  # ]:          0 :                                  pModule));
      67                 :            : }
      68                 :            : 
      69                 :          0 : ORealDynamicLoader::~ORealDynamicLoader()
      70                 :            : {
      71                 :            :     // set the address to zero
      72         [ #  # ]:          0 :     if( ppSetToZeroInDestructor )
      73                 :          0 :         *ppSetToZeroInDestructor = 0;
      74                 :            : 
      75         [ #  # ]:          0 :     if (m_pModule)
      76                 :            :     {
      77         [ #  # ]:          0 :         osl_unloadModule(m_pModule);
      78                 :          0 :         m_pModule = NULL;
      79                 :            :     }
      80         [ #  # ]:          0 : }
      81                 :            : 
      82                 :          0 : sal_uInt32 ORealDynamicLoader::acquire()
      83                 :            : {
      84                 :          0 :     return ++m_refCount;
      85                 :            : }
      86                 :            : 
      87                 :          0 : sal_uInt32 ORealDynamicLoader::release()
      88                 :            : {
      89                 :          0 :     sal_uInt32 nRet = --m_refCount;
      90         [ #  # ]:          0 :     if( nRet == 0 )
      91         [ #  # ]:          0 :         delete this;
      92                 :          0 :     return nRet;
      93                 :            : }
      94                 :            : 
      95                 :            : 
      96                 :          0 : void* ORealDynamicLoader::getApi() const
      97                 :            : {
      98                 :          0 :     return m_pApi;
      99                 :            : }
     100                 :            : 
     101                 :            : } // namespace salhelper
     102                 :            : 
     103                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10