35 #include "XrdVersion.hh"
47 XrdVersionInfo *vInfo,
65 XrdVersionInfo *vInfo,
74 errBP = (eBlen > 0 ? eBuff : 0);
75 errBL = (eBlen > 0 ? eBlen : 0);
77 if (errBP) *errBP = 0;
87 static const int ebsz = 2048;
91 errBP = (
char *)malloc(ebsz);
112 if (theLib) free(theLib);
113 if (altLib) free(altLib);
117 if (piP) {piP->
Persist();
delete piP;}
118 if (errBP && frBuff) free(errBP);
125 void XrdOucPinLoader::Inform(
const char *txt1,
const char *txt2,
126 const char *txt3,
const char *txt4,
132 if (eDest) {eDest->
Say(
"Config ", txt1, txt2, txt3, txt4, txt5);
return;}
140 {
int n = strlen(errBP);
141 if (n+16 > errBL)
return;
152 const char *eTxt[] = {txt1, txt2, txt3, txt4, txt5, 0};
153 while(bL > 1 && eTxt[i])
154 {n = snprintf(bP, bL,
"%s", eTxt[i]);
155 bP += n; bL -= n; i++;
163 void XrdOucPinLoader::Init(
const char *drctv,
const char *plib)
165 char *plib2 = 0, libBuf[2048];
181 {snprintf(libBuf,
sizeof(libBuf),
"'%s' wrongly coerces version "
182 "'-%d'; using '%s' instead!", plib, n, plib2);
184 snprintf(libBuf,
sizeof(libBuf),
"'%s' should not use '-%d' "
185 "version syntax in its name!", plib, n);
187 if (eDest) eDest->
Say(
"Config warning: ", dName,
" path ", libBuf);
188 if (plib2) plib = plib2;
194 libBuf,
sizeof(libBuf)))
195 {theLib = strdup(libBuf);
196 altLib = (noFallBack ? 0 : strdup(plib));
199 altLib = strdup(plib);
203 if (plib2) free(plib2);
210 bool XrdOucPinLoader::LoadLib(
int mcnt)
212 bool allMsgs = altLib == 0;
216 if (eDest) piP =
new XrdSysPlugin(eDest, theLib, dName, viP, mcnt);
217 else piP =
new XrdSysPlugin(errBP, errBL, theLib, dName, viP, mcnt);
221 if (piP->
getLibrary(allMsgs, global))
return true;
230 if (!altLib && errno != ENOENT)
237 if (eDest) eDest->
Say(
"Plugin ", dName,
" ", theLib,
238 " not found; falling back to using ", altLib);
253 if (eDest) piP =
new XrdSysPlugin(eDest, theLib, dName, viP, mcnt);
254 else piP =
new XrdSysPlugin(errBP, errBL, theLib, dName, viP, mcnt);
258 if (piP->
getLibrary(
true, global))
return true;
273 if (!theLib && !badLib)
274 {Inform(
"Unable to load ",dName,
" plugin ",altLib,
"; invalid path.");
282 if (badLib)
return 0;
287 if (!piP && !LoadLib(mcnt))
return 0;
291 if (*symP ==
'?' || *symP ==
'!')
293 isOptional = (*symP ==
'!' ? 1 : 2);
298 return piP->
getPlugin(symP, isOptional, global);
310 if (piP) {
delete piP; piP = 0;}
311 if (dodel)
delete this;
XrdOucPinLoader(XrdSysError *errP, XrdVersionInfo *vInfo, const char *drctv, const char *plib)
void * Resolve(const char *symbl, int mcnt=1)
void Unload(bool dodel=false)
static int Version(const char *piVers, const char *piPath, bool &noFBK, char *buff, int blen)
static int hasVersion(const char *piPath, char **piNoVN=0)
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
void * getPlugin(const char *pname, int optional=0)
void * getLibrary(bool allMsgs=true, bool global=false)