35 #include <sys/types.h>
49 #include "XrdVersion.hh"
58 static const char libSfx[] =
"/libXrdCksCalc%s.so";
66 snprintf(buff,
sizeof(buff),
"Version %s is incompatible with %s.",
68 verMsg = strdup(buff); urVersion = 0;
76 csTab[0].Name = strdup(
"adler32");
77 csTab[1].Name = strdup(
"crc32");
78 csTab[2].Name = strdup(
"md5");
85 ldPath = (
char *)malloc(n+
sizeof(libSfx)+1);
86 k = (libPath[n-1] ==
'/');
87 strcpy(ldPath, libPath);
88 strcpy(ldPath+n, libSfx+k);
89 }
else ldPath = strdup(libSfx+1);
99 for (i = 0; i <= csLast; i++)
100 {
if (csTab[i].Name) free( csTab[i].Name);
101 if (csTab[i].Obj) csTab[i].Obj->Recycle();
102 if (csTab[i].Plugin)
delete csTab[i].Plugin;
104 if (ldPath) free(ldPath);
105 if (verMsg) free(verMsg);
112 #define XRDOSSCKSLIBARGS XrdSysError *, const char *, const char *, const char *
115 char *eBuff,
int eBlen,
bool orig)
128 if (verMsg) {
if (eBuff) strncpy(eBuff, verMsg, eBlen);
return 0;}
132 if ((csIP = Find(csName)))
134 {
if (!strcmp(
"adler32", csIP->Name))
136 else if (!strcmp(
"crc32", csIP->Name))
138 else if (!strcmp(
"md5", csIP->Name))
140 else {
if (eBuff) snprintf(eBuff, eBlen,
"Logic error configuring %s "
141 "checksum.", csName);
145 return (orig ? csIP->Obj : csIP->Obj->New());
150 if (csLast+1 >= csMax)
151 {
if (eBuff) strncpy(eBuff,
"Maximum number of checksums loaded.", eBlen);
157 snprintf(ldBuff,
sizeof(ldBuff), ldPath, csName);
161 if (!(myPin =
new XrdOucPinLoader(eBuff,eBlen,urVersion,
"ckslib",ldBuff)))
167 (myPin->
Resolve(
"XrdCksCalcInit"))))
168 {myPin->
Unload(
true);
return 0;}
172 if (!(csObj = ep(0, 0, csName, csParms)))
174 snprintf(eBuff, eBlen,
"%s checksum initialization failed.", csName);
181 if (strcmp(csName, csObj->Type(n)))
183 snprintf(eBuff, eBlen,
"%s cksum plugin returned wrong name - %s",
184 csName, csObj->Type(n));
193 csTab[csLast].Name = strdup(csName);
194 csTab[csLast].Obj = csObj;
195 csTab[csLast].Plugin = myPin->
Export();
199 return (orig ? csObj : csObj->New());
206 XrdCksLoader::csInfo *XrdCksLoader::Find(
const char *Name)
209 for (i = 0; i <= csLast; i++)
210 if (!strcmp(Name, csTab[i].Name))
return &csTab[i];
XrdCksLoader(XrdVersionInfo &vInfo, const char *libPath=0)
XrdCksCalc * Load(const char *csName, const char *csParms=0, char *eBuff=0, int eBlen=0, bool orig=false)
~XrdCksLoader()
Destructor.
void * Resolve(const char *symbl, int mcnt=1)
void Unload(bool dodel=false)
static bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false)
XrdVERSIONINFODEF(myVersion, cmsclient, XrdVNUMBER, XrdVERSION)