LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/desktop/source/lib - shim.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 22 0.0 %
Date: 2013-07-09 Functions: 0 1 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             : 
      10             : #ifdef LINUX
      11             : 
      12             : #include <stdio.h>
      13             : #include <string.h>
      14             : 
      15             : #include <osl/module.h>
      16             : #include <sal/types.h>
      17             : #include <liblibreoffice.hxx>
      18             : 
      19             : #include <dlfcn.h>
      20             : #ifdef AIX
      21             : #  include <sys/ldr.h>
      22             : #endif
      23             : 
      24             : #define TARGET_LIB SAL_MODULENAME( "sofficeapp" )
      25             : 
      26             : extern "C" {
      27             :     typedef LibLibreOffice *(HookFunction)(void);
      28             : };
      29             : 
      30           0 : SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path )
      31             : {
      32           0 :     if( !install_path )
      33           0 :         return NULL;
      34           0 :     char* imp_lib = (char *) malloc( strlen (install_path) + sizeof( TARGET_LIB ) + 2 );
      35           0 :     if(!imp_lib)
      36             :     {
      37           0 :         fprintf( stderr, "failed to open library : not enough memory\n");
      38           0 :         return NULL;
      39             :     }
      40           0 :     strcpy( imp_lib, install_path );
      41           0 :     strcat( imp_lib, "/" );
      42           0 :     strcat( imp_lib, TARGET_LIB );
      43           0 :     void *dlhandle = dlopen( imp_lib, RTLD_LAZY );
      44           0 :     if( !dlhandle )
      45             :     {
      46           0 :         fprintf( stderr, "failed to open library '%s'\n", imp_lib );
      47           0 :         free( imp_lib );
      48           0 :         return NULL;
      49             :     }
      50             : 
      51           0 :     HookFunction *pSym = (HookFunction *) dlsym( dlhandle, "liblibreoffice_hook" );
      52           0 :     if( !pSym ) {
      53           0 :         fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
      54           0 :         free( imp_lib );
      55           0 :         return NULL;
      56             :     }
      57             : 
      58           0 :     free( imp_lib );
      59           0 :     return pSym();
      60             : }
      61             : 
      62             : #endif // LINUX - port me !
      63             : 
      64             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10