XRootD
XrdOucPreload.cc File Reference
#include <cstdio>
#include "XrdVersion.hh"
#include "XrdOuc/XrdOucVerName.hh"
#include "XrdOuc/XrdOucPreload.hh"
#include "XrdSys/XrdSysPlugin.hh"
+ Include dependency graph for XrdOucPreload.cc:

Go to the source code of this file.

Functions

bool XrdOucPreload (const char *plib, char *eBuff, int eBlen, bool retry)
 This include file define a utility function that pre-loads a plugin. More...
 

Function Documentation

◆ XrdOucPreload()

bool XrdOucPreload ( const char *  plib,
char *  eBuff,
int  eBlen,
bool  retry = false 
)

This include file define a utility function that pre-loads a plugin.

Preload a plugin and persist its image. Internal plugin version checking is performed when the plugin is actually initialized.

Parameters
plibPointer to the shared library path that contains the plugin.
eBuffPointer to a buffer tat is to receive any messages. Upon failure it will contain an eror message. Upon success it will contain an informational message that describes the version that was loaded.
eBlenThe length of the eBuff, it should be at least 1K to avoid message truncation as the message may have a path.
retryWhen true: if the version name of the plugin is not found, try to preload the unversioned name. When false: Only the versioned name of the plugin may be preloaded (i.e. libXXXX-n.so).
Returns
true The plugin was successfully loaded.
false The plugin could not be loaded, eBuff contains the reason.

Definition at line 42 of file XrdOucPreload.cc.

43 {
44  char theLib[2048];
45  bool dummy;
46 
47 // Perform versioning
48 //
49  if (!XrdOucVerName::Version(XRDPLUGIN_SOVERSION, plib, dummy,
50  theLib, sizeof(theLib)))
51  {snprintf(eBuff, eBlen,
52  "Unable to preload plugin via %s; path too long.", plib);
53  return false;
54  }
55 
56 // Preload the library. If we failed, we will try to fallback to the
57 // unversioned name is we are allowed to do so.
58 //
59  *eBuff = 0;
60  if (XrdSysPlugin::Preload(theLib, eBuff, eBlen)
61  || (retry && XrdSysPlugin::Preload(plib, eBuff, eBlen))) return true;
62  return false;
63 }
static int Version(const char *piVers, const char *piPath, bool &noFBK, char *buff, int blen)
static bool Preload(const char *path, char *ebuff=0, int eblen=0)

References XrdSysPlugin::Preload(), and XrdOucVerName::Version().

+ Here is the call graph for this function: