This file is indexed.

/usr/include/root/Reflex/SharedLibrary.h is in libroot-core-dev 5.34.00-2.

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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// @(#)root/reflex:$Id: SharedLibrary.h 42838 2012-01-31 17:06:48Z axel $
// Author: Stefan Roiser 2006

// Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose is hereby granted without fee, provided that this copyright and
// permissions notice appear in all copies and derivatives.
//
// This software is provided "as is" without express or implied warranty.

#ifndef Reflex_SharedLibrary
#define Reflex_SharedLibrary

// Include files
#ifdef _WIN32
# include <windows.h>
#else
# include <dlfcn.h>
# include <errno.h>
#endif


namespace Reflex {
/**
 * @class SharedLibrary SharedLibrary.h Reflex/SharedLibrary.h
 * @author Stefan Roiser
 * @date 24/11/2006
 * @ingroup Ref
 * Parts of this implementation are copyied from SEAL (http://cern.ch/seal)
 */
class SharedLibrary {
public:
   SharedLibrary(const std::string& libname);

   bool Load();

   bool Unload();

   bool Symbol(const std::string& symname,
               void*& sym);

   std::string Error();

private:
   /** a handle to the loaded library */
#ifdef _WIN32
   HMODULE fHandle;
#else
   void* fHandle;
#endif
   /** the name of the shared library to handle */
   std::string fLibName;
};

} // namespace Reflex


//-------------------------------------------------------------------------------
inline Reflex::SharedLibrary::SharedLibrary(const std::string& libname):
//-------------------------------------------------------------------------------
   fHandle(0),
   fLibName(libname) {
}


//-------------------------------------------------------------------------------
inline std::string
Reflex::SharedLibrary::Error() {
//-------------------------------------------------------------------------------
   std::string errString;
#ifdef _WIN32
   int error = ::GetLastError();
   LPVOID lpMessageBuffer;
   ::FormatMessage(
      FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
      NULL,
      error,
      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language
      (LPTSTR) &lpMessageBuffer,
      0,
      NULL);
   errString = (const char*) lpMessageBuffer;
   // Free the buffer allocated by the system
   ::LocalFree(lpMessageBuffer);
#else
   const char* err = dlerror();
   if (err) {
      errString = err;
   }
#endif
   return errString;
} // Error


//-------------------------------------------------------------------------------
inline bool
Reflex::SharedLibrary::Load() {
//-------------------------------------------------------------------------------

#ifdef _WIN32
   ::SetErrorMode(0);
   fHandle = ::LoadLibrary(fLibName.c_str());
#else
   fHandle = ::dlopen(fLibName.c_str(), RTLD_LAZY | RTLD_GLOBAL);
#endif

   if (!fHandle) {
      return false;
   } else { return true; }
}


//-------------------------------------------------------------------------------
inline bool
Reflex::SharedLibrary::Symbol(const std::string& symname,
                              void*& sym) {
//-------------------------------------------------------------------------------

   if (fHandle) {
#ifdef _WIN32
      sym = GetProcAddress(fHandle, symname.c_str());
#else
      sym = dlsym(fHandle, symname.c_str());
#endif

      if (sym) {
         return true;
      }
   }
   return false;
}


//-------------------------------------------------------------------------------
inline bool
Reflex::SharedLibrary::Unload() {
//-------------------------------------------------------------------------------

#ifdef _WIN32

   if (FreeLibrary(fHandle) == 0) {
      return false;
   }
#else

   if (dlclose(fHandle) == -1) {
      return false;
   }
#endif
   else { return true; }
}


#endif // Reflex_SharedLibrary