LCOV - code coverage report
Current view: top level - libreoffice/soltools/checkdll - checkdll.c (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 24 0.0 %
Date: 2012-12-27 Functions: 0 2 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             : 
      21             : #include <stdio.h>
      22             : #include <string.h>
      23             : #include <errno.h>
      24             : #include <unistd.h>
      25             : #include <dlfcn.h>
      26             : 
      27             : /*
      28             :  * NOTE: Since no one is really interested in correct unload behavior I've
      29             :  * disabled the shared library unload check. If you want to reenable it comment
      30             :  * the following line out
      31             :  */
      32             : #define NO_UNLOAD_CHECK
      33             : 
      34             : static const char *pprog_name   = "checkdll";
      35             : static const char *psymbol      = "GetVersionInfo";
      36             : 
      37           0 : void usage()
      38             : {
      39           0 :     fprintf(stderr, "usage: %s [-s] <dllname>\n", pprog_name);
      40           0 :     return;
      41             : }
      42             : 
      43           0 : int main(int argc, char *argv[])
      44             : {
      45           0 :     int     silent=0;
      46             :     void    *phandle;
      47             :     char    *(*pfun)(void);
      48             : 
      49           0 :     if ( argc < 2 || argc > 4) {
      50           0 :         usage();
      51           0 :         return 1;
      52             :     }
      53             : 
      54           0 :     if ( !strcmp(argv[1],"-s") ) {
      55           0 :         silent = 1;
      56           0 :         ++argv, --argc;
      57             :     }
      58             : 
      59           0 :     if ( access( argv[1], R_OK ) == -1 ) {
      60           0 :         fprintf(stderr, "%s: ERROR: %s: %s\n",
      61           0 :                 pprog_name, argv[1], strerror(errno));
      62           0 :         return 2;
      63             :     }
      64             : 
      65           0 :     if (!silent) printf("Checking DLL %s ...", argv[1]);
      66           0 :     fflush(stdout);
      67             : 
      68           0 :     if ( (phandle = dlopen(argv[1], RTLD_NOW)) != NULL ) {
      69           0 :         if  ( (pfun = (char *(*)(void))dlsym(phandle, psymbol)) != NULL ) {
      70           0 :             if (!silent) printf(": ok\n");
      71             :         }
      72             :         else
      73             :         {
      74           0 :             printf(": WARNING: %s\n", dlerror());
      75             :         }
      76             : #ifdef NO_UNLOAD_CHECK
      77           0 :         _exit(0);
      78             : #else
      79             :         dlclose(phandle);
      80             : #endif
      81             :         return 0;
      82             :     }
      83             : 
      84           0 :     printf(": ERROR: %s\n", dlerror());
      85           0 :     return 3;
      86             : }
      87             : 
      88             : 
      89             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10