XRootD
XrdOucPreload.cc
Go to the documentation of this file.
1 /******************************************************************************/
2 /* */
3 /* X r d O u c P r e l o a d . c c */
4 /* */
5 /* (c) 2014 by the Board of Trustees of the Leland Stanford, Jr., University */
6 /* Produced by Andrew Hanushevsky for Stanford University under contract */
7 /* DE-AC02-76-SFO0515 with the Department of Energy */
8 /* */
9 /* This file is part of the XRootD software suite. */
10 /* */
11 /* XRootD is free software: you can redistribute it and/or modify it under */
12 /* the terms of the GNU Lesser General Public License as published by the */
13 /* Free Software Foundation, either version 3 of the License, or (at your */
14 /* option) any later version. */
15 /* */
16 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19 /* License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24 /* */
25 /* The copyright holder's institutional names and contributor's names may not */
26 /* be used to endorse or promote products derived from this software without */
27 /* specific prior written permission of the institution or contributor. */
28 /******************************************************************************/
29 
30 #include <cstdio>
31 
32 #include "XrdVersion.hh"
33 
34 #include "XrdOuc/XrdOucVerName.hh"
35 #include "XrdOuc/XrdOucPreload.hh"
36 #include "XrdSys/XrdSysPlugin.hh"
37 
38 /******************************************************************************/
39 /* X r d O u c P r e l o a d */
40 /******************************************************************************/
41 
42 bool XrdOucPreload(const char *plib, char *eBuff, int eBlen, bool retry)
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 }
bool XrdOucPreload(const char *plib, char *eBuff, int eBlen, bool retry)
This include file define a utility function that pre-loads a plugin.
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)