This file is indexed.

/usr/include/claw/dynamic_library_traits_unix.hpp is in libclaw-dynamic-library-dev 1.7.3-1+b2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
  CLAW - a C++ Library Absolutely Wonderful

  CLAW is a free library without any particular aim but being useful to 
  anyone.

  Copyright (C) 2005-2011 Julien Jorge

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  contact: julien.jorge@gamned.org
*/
/**
 * \file dynamic_library_traits_unix.hpp
 * \brief Unix interface for using dynamic libraries.
 * \author Julien Jorge
 */
#ifndef __CLAW_DYNAMIC_LIBRARY_TRAITS_UNIX_HPP__
#define __CLAW_DYNAMIC_LIBRARY_TRAITS_UNIX_HPP__

#include <string>
#include <dlfcn.h>
#include <claw/exception.hpp>

namespace claw
{
  /**
   * \brief Unix interface for using dynamic libraries.
   * \author Julien Jorge
   */
  class dynamic_library_traits_unix
  {
  public:
     /** \brief Type of the system handle to the library. */
    typedef void* handle;

  public:
    /*------------------------------------------------------------------------*/
    /**
     * \brief Open a library.
     * \param name The name of the library to open.
     * \return The handle on the loaded library.
     */
    static handle open( const std::string& name )
    {
      handle h = dlopen( name.c_str(), RTLD_LAZY );

      if ( !valid_handle(h) )
        throw claw::exception( dlerror() );

      return h;
    } // dynamic_library_traits_unix::open()

    /*------------------------------------------------------------------------*/
    /**
     * \brief Open the current program.
     * \param name (not used) The name of the current program.
     * \return The handle on the loaded library.
     */
    static handle auto_open( const std::string& name )
    {
      handle h = dlopen( NULL, RTLD_LAZY );

      if ( !valid_handle(h) )
        throw claw::exception( dlerror() );

      return h;
    } // dynamic_library_traits_unix::auto_open()

    /*------------------------------------------------------------------------*/
    /**
     * \brief Close a library.
     * \param h The handle of the library to close.
     */
    static void close( handle h )
    {
      dlclose(h);
    } // dynamic_library_traits_unix::close()

    /*------------------------------------------------------------------------*/
    /**
     * \brief Get a symbol from a library.
     * \param h Handle of the library.
     * \param name The name of the symbol to load.
     */
    template<class T>
    static T get_symbol( handle h, const std::string& name )
    {
      /* HACK : ISO standard doesn't allow to cast from a pointer to an object
         to a pointer to a function. */
      T result;
      *(void**)(&result) = dlsym( h, name.c_str() );

      return result;
    } // dynamic_library_traits_unix::get_symbol()

    /*------------------------------------------------------------------------*/
    /**
     * \brief Tell if a symbol is in the library.
     * \param h Handle of the library.
     * \param name The name of the symbol to find.
     */
    static bool have_symbol( handle h, const std::string& name )
    {
      return dlsym( h, name.c_str() ) != NULL;
    } // dynamic_library_traits_unix::have_symbol()

    /*------------------------------------------------------------------------*/
    /**
     * \brief Tell if an handle is a valid library handle.
     * \param h The handle to test.
     */
    static bool valid_handle( handle h )
    {
      return h != NULL;
    } // dynamic_library_traits_unix::valid_handle()

  }; // class dynamic_library_traits_unix

  /** \brief The traits to access the dynamic libraries in Unix system. */
  typedef dynamic_library_traits_unix dynamic_library_traits;

} // namespace claw

#endif // __CLAW_DYNAMIC_LIBRARY_TRAITS_UNIX_HPP__