XRootD
XrdOucVerName Class Reference

#include <XrdOucVerName.hh>

+ Collaboration diagram for XrdOucVerName:

Static Public Member Functions

static int hasVersion (const char *piPath, char **piNoVN=0)
 
static int Version (const char *piVers, const char *piPath, bool &noFBK, char *buff, int blen)
 

Detailed Description

XrdOucVerName

This class performs name versioning for shared library plug-ins.

Definition at line 38 of file XrdOucVerName.hh.

Member Function Documentation

◆ hasVersion()

int XrdOucVerName::hasVersion ( const char *  piPath,
char **  piNoVN = 0 
)
static

Test if plugin path contains a version number.

Parameters
piPathPointer to the original path to the plug-in.
piNoVN!= 0: If piPath has a version, an strdup'd path without a version is returned. Otherwise, nil is returned. == 0: Does not return an alternate path.
Returns
>0 the version number if path contains a version.
=0 the path does not contain a version number.

Definition at line 52 of file XrdOucVerName.cc.

53 {
54  const char *Dash;
55 
56 // We check for an embeded version number. This is usually used to issue a
57 // warning that including a specific version disables automatic versioning.
58 // We only return an alternate name if the library is an official one.
59 //
60  if ((Dash = rindex(piPath, '-')))
61  {char *endP;
62  int vn = strtol(Dash+1, &endP, 10);
63  if (vn && !strcmp(endP, ".so"))
64  {if (piNoVN)
65  {char buff[2048];
66  snprintf(buff,sizeof(buff),"%.*s%s",int(Dash-piPath),piPath,endP);
67  if (isOurs(buff)) *piNoVN = strdup(buff);
68  else *piNoVN = 0;
69  }
70  return vn;
71  }
72  }
73  if (piNoVN) *piNoVN = 0;
74  return 0;
75 }

◆ Version()

int XrdOucVerName::Version ( const char *  piVers,
const char *  piPath,
bool &  noFBK,
char *  buff,
int  blen 
)
static

Version a plug-in library path.

Parameters
piVersPointer to the version string to be used.
piPathPointer to the original path to the plug-in.
noFBKUpon return is set to true if the versioned name has no fallback name and must be loaded with the resulting path.
buffPointer to abuffer that will hold the resulting path.
blenThe size of the buffer.
Returns
success The length of the reulting path in buff withe eqName set.
failure Zero (buffer is too small) but eqName is still set.

Definition at line 96 of file XrdOucVerName.cc.

98 {
99  const char *Dot, *Slash, *fName;
100  int n, pLen;
101 
102 // Find the markers in the passed path
103 //
104  if ((Slash = rindex(piPath, '/')))
105  {pLen = Slash-piPath+1; Dot = rindex(Slash+1, '.'); fName = Slash+1;}
106  else {pLen = 0; Dot = rindex(piPath, '.'); fName = piPath;}
107  if (Dot) pLen += Dot-fName;
108  else {pLen += strlen(fName); Dot = "";}
109 
110 // Test strict naming and return result
111 //
112  n = 0;
113  while(StrictName[n] && strcmp(fName, StrictName[n])) n++;
114  noFBK = (StrictName[n] != 0);
115 
116 // Format the versioned name
117 //
118  n = snprintf(buff, blen-1, "%.*s-%s%s", pLen, piPath, piVers, Dot);
119 
120 // Return result
121 //
122  return (n < blen ? n : 0);
123 }

Referenced by XrdOucPinPath(), and XrdOucPreload().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: