XRootD
XrdLinkMatch Class Reference

#include <XrdLinkMatch.hh>

+ Collaboration diagram for XrdLinkMatch:

Public Member Functions

 XrdLinkMatch (const char *target=0)
 
 ~XrdLinkMatch ()
 
int Match (const char *uname, int unlen, const char *hname)
 
int Match (const char *uname, int unlen, const char *hname, int hnlen)
 
void Set (const char *target)
 

Detailed Description

Definition at line 34 of file XrdLinkMatch.hh.

Constructor & Destructor Documentation

◆ XrdLinkMatch()

XrdLinkMatch::XrdLinkMatch ( const char *  target = 0)
inline

Definition at line 49 of file XrdLinkMatch.hh.

50  {Uname = HnameL = HnameR = 0;
51  Unamelen = Hnamelen = 0;
52  if (target) Set(target);
53  }
void Set(const char *target)
Definition: XrdLinkMatch.cc:69

References Set().

+ Here is the call graph for this function:

◆ ~XrdLinkMatch()

XrdLinkMatch::~XrdLinkMatch ( )
inline

Definition at line 55 of file XrdLinkMatch.hh.

55 {}

Member Function Documentation

◆ Match() [1/2]

int XrdLinkMatch::Match ( const char *  uname,
int  unlen,
const char *  hname 
)
inline

Definition at line 41 of file XrdLinkMatch.hh.

43  {return Match(uname, unlen, hname, strlen(hname));}
int Match(const char *uname, int unlen, const char *hname, int hnlen)
Definition: XrdLinkMatch.cc:39

References Match().

+ Here is the call graph for this function:

◆ Match() [2/2]

int XrdLinkMatch::Match ( const char *  uname,
int  unlen,
const char *  hname,
int  hnlen 
)

Definition at line 39 of file XrdLinkMatch.cc.

41 {
42 
43 // Check if we should try to match the username
44 //
45  if (Unamelen && (Unamelen > unlen+1 || strncmp(uname,Uname,Unamelen))) return 0;
46 
47 // Check if we should match the full host name
48 //
49  if (HnameL && !HnamelenL) return !strcmp(HnameL, hname);
50 
51 // Check if prefix suffix matching might succeed
52 //
53  if (HnamelenL > hnlen) return 0;
54 
55 // Check if we should match the host name prefix
56 //
57  if (HnameL && strncmp(HnameL, hname, HnamelenL)) return 0;
58 
59 // Check if we should match the host name suffix
60 //
61  if (!HnameR) return 1;
62  return !strcmp(hname+hnlen-HnamelenR, hname);
63 }

Referenced by XrdLinkCtl::Find(), XrdLinkCtl::getName(), and Match().

+ Here is the caller graph for this function:

◆ Set()

void XrdLinkMatch::Set ( const char *  target)

Definition at line 69 of file XrdLinkMatch.cc.

70 {
71  char *theast;
72 
73 // Free any existing target
74 //
75  if (!target || !strcmp(target, "*"))
76  {Uname = HnameL = HnameR = 0;
77  Unamelen = HnamelenL = HnamelenR = 0;
78  return;
79  }
80  strlcpy(Buff, target, sizeof(Buff)-1);
81  Uname = Buff;
82 
83 // Find the '@' as the pivot in this name
84 //
85  if (!(HnameL = index(Uname, '@')))
86  {if ((Unamelen = strlen(Uname)))
87  {if (Uname[Unamelen-1] == '*') Unamelen--;
88  else if (index(Uname, ':')) Uname[Unamelen++] = '@';
89  else if (index(Uname, '.')) Uname[Unamelen++] = ':';
90  else Uname[Unamelen++] = '.';
91  }
92  HnameR = 0;
93  return;
94  }
95 
96 // We have a form of <string>@<string>
97 //
98  *HnameL++ = '\0';
99  if ((Unamelen = strlen(Uname)))
100  {if (Uname[Unamelen-1] == '*') Unamelen--;
101  else if (index(Uname, ':')) Uname[Unamelen++] = '@';
102  else if (index(Uname, '.')) Uname[Unamelen++] = ':';
103  else Uname[Unamelen++] = '.';
104  }
105 
106 // The post string may have an asterisk.
107 //
108  if (!(theast = index(HnameL, '*')))
109  {HnamelenL = 0;
110  HnameR = 0;
111  return;
112  }
113 
114 // Indicate how much of the prefix should match
115 //
116  *theast = '\0';
117  if (!(HnamelenL = strlen(HnameL))) HnameL = 0;
118 
119 // Indicate how much of the suffix should match
120 //
121  if ((HnamelenR = strlen(theast))) HnameR = theast+1;
122  else HnameR = 0;
123  Hnamelen = HnamelenL+HnamelenR;
124 }
size_t strlcpy(char *dst, const char *src, size_t sz)

References strlcpy().

Referenced by XrdLinkMatch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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