LCOV - code coverage report
Current view: top level - desktop/source/lib - shim.c (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 21 0.0 %
Date: 2014-04-14 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.h>
      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             : typedef LibreOffice *(HookFunction)(void);
      27             : 
      28           0 : SAL_DLLPUBLIC_EXPORT LibreOffice *lo_init( const char *install_path )
      29             : {
      30             :     char *imp_lib;
      31             :     void *dlhandle;
      32             :     HookFunction *pSym;
      33             : 
      34           0 :     if( !install_path )
      35           0 :         return NULL;
      36           0 :     if( !( imp_lib = (char *) malloc( strlen (install_path) + sizeof( TARGET_LIB ) + 2 ) ) )
      37             :     {
      38           0 :         fprintf( stderr, "failed to open library : not enough memory\n");
      39           0 :         return NULL;
      40             :     }
      41             : 
      42           0 :     strcpy( imp_lib, install_path );
      43           0 :     strcat( imp_lib, "/" );
      44           0 :     strcat( imp_lib, TARGET_LIB );
      45             : 
      46           0 :     if( !( dlhandle = dlopen( imp_lib, RTLD_LAZY ) ) )
      47             :     {
      48           0 :         fprintf( stderr, "failed to open library '%s'\n", imp_lib );
      49           0 :         free( imp_lib );
      50           0 :         return NULL;
      51             :     }
      52             : 
      53           0 :     pSym = (HookFunction *) dlsym( dlhandle, "liblibreoffice_hook" );
      54           0 :     if( !pSym ) {
      55           0 :         fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
      56           0 :         dlclose( dlhandle );
      57           0 :         free( imp_lib );
      58           0 :         return NULL;
      59             :     }
      60             : 
      61           0 :     free( imp_lib );
      62           0 :     return pSym();
      63             : }
      64             : 
      65             : #endif // not LINUX => port me !
      66             : 
      67             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10