xrootd
XrdOssPath.hh
Go to the documentation of this file.
1 #ifndef _OSS_PATH_H
2 #define _OSS_PATH_H
3 /******************************************************************************/
4 /* */
5 /* X r d O s s P a t h . h h */
6 /* */
7 /* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 #include <string.h>
14 
16 {
17 public:
18 
19 struct fnInfo
20 {
21 const char *Path;
22 const char *Sfx; // Of length sfxLen!
23  char *Slash;
24  int Plen;
25 };
26 
27 static const char xChar = '%';
28 
29 static const int sfxLen = 4;
30 
31 static int Convert(char *dst, int dln, const char *oldP, const char *newP);
32 
33 static
34 const char *Extract(char *path, char *lbuf, int &lbsz);
35 
36 static char *genPath(const char *inPath, const char *cgrp, char *sfx);
37 
38 static char *genPFN(fnInfo &Info, char *buff, int blen, const char *Path=0);
39 
40 static char *genPFN(char *dst, int dln, const char *src);
41 
42 static int getCname(const char *path, char *Cache, char *lbuf=0, int lbsz=0);
43 
44 static
45 inline int isXA(const char *path) {return path[strlen(path)-1] == xChar;}
46 
47 enum theSfx {isBase =0, isAnew =1,
48  sfxMigF=1, isFail=2, isLock =3, isPin =4, sfxMigL=4,
50  isPfn=8, sfxLast=8, sfxNum =9
51  };
52 
53 static
54 const char *Sfx[sfxNum];
55 
56 static const int chkMem = 0x01;
57 static const int chkMig = 0x02;
58 static const int chkPfn = 0x04;
59 static const int chkAll = 0x07;
60 
61 static theSfx pathType(const char *Path, int chkWhat=chkAll);
62 
63 static void Trim2Base(char *eP);
64 
67 
68 private:
69 static char *bin2hex(char *inbuff, int dlen, char *buff);
70 static int Init(char *pfnPfx);
71 static char *posCname(char *lbuf, int lbsz, int &cnsz);
72 
73 static char h2c[16];
74 };
75 #endif