XRootD
Loading...
Searching...
No Matches
XrdOucN2No2p.cc File Reference
#include <algorithm>
#include <cerrno>
#include <cstdio>
#include <string>
#include <cstring>
#include <unistd.h>
#include "XrdVersion.hh"
#include "XrdOuc/XrdOucName2Name.hh"
#include "XrdOuc/XrdOucTokenizer.hh"
#include "XrdSys/XrdSysError.hh"
+ Include dependency graph for XrdOucN2No2p.cc:

Go to the source code of this file.

Classes

class  XrdOucN2No2p
 

Functions

XrdOucName2Name * XrdOucgetName2Name (XrdOucgetName2NameArgs)
 
unsigned long XrdOucHashVal2 (const char *KeyVal, int KeyLen)
 
 XrdVERSIONINFO (XrdOucgetName2Name, "XrdN2No2p")
 

Function Documentation

◆ XrdOucgetName2Name()

XrdOucName2Name * XrdOucgetName2Name ( XrdOucgetName2NameArgs )

Definition at line 197 of file XrdOucN2No2p.cc.

198{
199 struct bHelper {char *p; bHelper(const char *bP) : p(bP ? strdup(bP) : 0) {}
200 ~bHelper() {if (p) free(p);}
201 };
202 bHelper prms(parms);
203 const char *oPfx;
204 char *val, *eP;
205 std::string ostr;
206 int fnMax = 0, n;
207 char sChar = '\\';
208
209// Process options
210//
211 XrdOucTokenizer toks(prms.p);
212 toks.GetLine();
213 while((val = toks.GetToken()) && *val)
214 { if (!strcmp(val, "-slash"))
215 {if (!(val = toks.GetToken()) || !(*val))
216 {eDest->Emsg("N2No2p", "-slash argument not specified.");
217 return 0;
218 }
219 if (strlen(val) == 1) {sChar = *val; continue;}
220 n = strtol(val, &eP, 16);
221 if (n & 0xff || *eP)
222 {eDest->Emsg("N2No2p", "Invalid -slash argument -",val);
223 return 0;
224 }
225 sChar = static_cast<char>(n);
226 }
227 else if (!strcmp(val, "-maxfnlen"))
228 {if (!(val = toks.GetToken()) || !(*val))
229 {eDest->Emsg("N2No2p", "-maxfnlen argument not specified.");
230 return 0;
231 }
232 fnMax = strtol(val, &eP, 16);
233 if (fnMax <= 0 || *eP)
234 {eDest->Emsg("N2No2p", "Invalid -maxfnlen argument -",val);
235 return 0;
236 }
237 }
238 else break;
239 }
240
241// Obtain the objectid prefix we are to use (default is '/')
242//
243 if (!val || !(*val)) oPfx = "/";
244 else {if (*val != '/')
245 {eDest->Emsg("N2No2p", "Invalid object ID path prefix -", val);
246 return 0;
247 }
248 oPfx = val;
249 n = strlen(val);
250 if (val[n-1] != '/') {ostr = val; ostr += '/'; oPfx = ostr.c_str();}
251 }
252
253// Now determine what the maximum filename length if not specified
254//
255 if (!fnMax)
256 if ((fnMax = pathconf("/", _PC_NAME_MAX)) < 0)
257 {eDest->Emsg("N2No2p", errno, "determine -fnmaxlen for '/'; using 255.");
258 fnMax = 255;
259 }
260
261// Return a new n2n object
262//
263 return new XrdOucN2No2p(eDest, lroot, oPfx, fnMax, sChar);
264}
static XrdSysError eDest(0,"crypto_")
long pathconf(const char *path, int name)

References eDest, XrdOucTokenizer::GetLine(), XrdOucTokenizer::GetToken(), pathconf(), and XrdOucgetName2NameArgs.

Referenced by XrdOucN2NLoader::Load(), and XrdVERSIONINFO().

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

◆ XrdOucHashVal2()

unsigned long XrdOucHashVal2 ( const char * KeyVal,
int KeyLen )
extern

Definition at line 57 of file XrdOucHashVal.cc.

58{ int j;
59 const char *cp;
60 unsigned long hval = 0;
61 int hl = sizeof(hval);
62
63// If name is shorter than the hash length, use the name.
64//
65 if (KeyLen <= hl) return LoadWord(KeyVal, (size_t)KeyLen);
66
67// Compute the length of the name and develop starting hash.
68//
69 hval = KeyLen;
70 j = KeyLen % hl; KeyLen /= hl;
71 if (j) hval ^= LoadWord(KeyVal);
72 cp = &KeyVal[j];
73
74// Compute and return the full hash. The key is walked with a byte pointer
75// since it is not aligned for unsigned long; LoadWord() does the unaligned
76// load, and the word arithmetic happens on the copy.
77//
78 while(KeyLen--)
79 {hval ^= LoadWord(cp);
80 cp += hl;
81 }
82 return (hval ? hval : 1);
83}

Referenced by XrdOucN2No2p::pfn2lfn(), and XrdOucHashVal().

+ Here is the caller graph for this function:

◆ XrdVERSIONINFO()

XrdVERSIONINFO ( XrdOucgetName2Name ,
"XrdN2No2p"  )

References XrdOucgetName2Name().

+ Here is the call graph for this function: