XRootD
Loading...
Searching...
No Matches
XrdOucN2NLoader.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d O u c N 2 N L o a d e r . c c */
4/* */
5/* (c) 2012 by the Board of Trustees of the Leland Stanford, Jr., University */
6/* All Rights Reserved */
7/* Produced by Andrew Hanushevsky for Stanford University under contract */
8/* DE-AC02-76-SFO0515 with the Department of Energy */
9/* */
10/* This file is part of the XRootD software suite. */
11/* */
12/* XRootD is free software: you can redistribute it and/or modify it under */
13/* the terms of the GNU Lesser General Public License as published by the */
14/* Free Software Foundation, either version 3 of the License, or (at your */
15/* option) any later version. */
16/* */
17/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20/* License for more details. */
21/* */
22/* You should have received a copy of the GNU Lesser General Public License */
23/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25/* */
26/* The copyright holder's institutional names and contributor's names may not */
27/* be used to endorse or promote products derived from this software without */
28/* specific prior written permission of the institution or contributor. */
29/******************************************************************************/
30
31#include <cerrno>
32#include <unistd.h>
33#include <sys/types.h>
34#include <sys/stat.h>
35
36#include "XrdVersion.hh"
37#include "XrdOuc/XrdOucEnv.hh"
40#include "XrdSys/XrdSysError.hh"
42
43/******************************************************************************/
44/* L o a d */
45/******************************************************************************/
46
48 XrdVersionInfo &urVer,
49 XrdOucEnv *envP)
50{
53 static XrdVERSIONINFODEF (myVer, XrdN2N, XrdVNUMBER, XrdVERSION);
54 XrdOucName2Name *n2nP;
56
57// Use the default mapping if there is no library. Verify version numbers
58// as we are normally in a different shared library.
59//
60 if (!libName)
61 {if (!XrdSysPlugin::VerCmp(urVer, myVer)) return 0;
62 if (lclRoot)
63 {struct stat Stat;
64 if (stat(lclRoot, &Stat))
65 {eRoute->Emsg("N2N", errno, "use localroot", lclRoot);
66 return 0;
67 }
68 if (!S_ISDIR(Stat.st_mode))
69 {eRoute->Emsg("N2N", ENOTDIR, "use localroot", lclRoot);
70 return 0;
71 }
72 XrdOucEnv::Export("XRDLCLROOT", lclRoot);
73 }
74 if (rmtRoot) XrdOucEnv::Export("XRDRMTROOT", rmtRoot);
75 n2nP = XrdOucgetName2Name(eRoute, cFN, libParms, lclRoot, rmtRoot);
76 if (XrdOucN2NVec_P && envP)
77 envP->PutPtr("XrdOucName2NameVec*", XrdOucN2NVec_P);
78 return n2nP;
79 } else {
80 XrdOucEnv::Export("XRDN2NLIB", libName);
81 if (libParms) XrdOucEnv::Export("XRDN2NPARMS", libParms);
82 }
83
84// Get the entry point of the object creator
85//
86 XrdOucPinLoader myLib(eRoute, &urVer, "namelib", libName);
87 ep = (XrdOucName2Name *(*)(XrdOucgetName2NameArgs))(myLib.Resolve("XrdOucgetName2Name"));
88 if (!ep) return 0;
89
90// Get the Object now
91//
92 if ((n2nP = ep(eRoute, cFN, libParms, lclRoot, rmtRoot)) && envP)
93 {n2nV = (XrdOucName2NameVec *)myLib.Resolve("?Name2NameVec");
94 if (n2nV) envP->PutPtr("XrdOucName2NameVec*", n2nV);
95 }
96 return n2nP;
97}
struct stat Stat
Definition XrdCks.cc:49
static XrdVERSIONINFODEF(compiledVer, XrdHttpProtocolTest, XrdVNUMBER, XrdVERSION)
XrdOucName2Name * XrdOucgetName2Name(XrdOucgetName2NameArgs)
XrdOucName2NameVec * XrdOucN2NVec_P
#define XrdOucgetName2NameArgs
#define stat(a, b)
Definition XrdPosix.hh:101
static int Export(const char *Var, const char *Val)
Definition XrdOucEnv.cc:170
void PutPtr(const char *varname, void *value)
Definition XrdOucEnv.cc:298
XrdOucName2Name * Load(const char *libName, XrdVersionInfo &urVer, XrdOucEnv *envP=0)
XrdOucName2NameVec *Name2NameVec;.
void * Resolve(const char *symbl, int mcnt=1)
static bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false)