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 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <string.h>
34 
36 {
37 public:
38 
39 struct fnInfo
40 {
41 const char *Path;
42 const char *Sfx; // Of length sfxLen!
43  char *Slash;
44  int Plen;
45 };
46 
47 static const char xChar = '%';
48 
49 static const int sfxLen = 4;
50 
51 static int Convert(char *dst, int dln, const char *oldP, const char *newP);
52 
53 static
54 const char *Extract(char *path, char *lbuf, int &lbsz);
55 
56 static char *genPath(const char *inPath, const char *cgrp, char *sfx);
57 
58 static char *genPFN(fnInfo &Info, char *buff, int blen, const char *Path=0);
59 
60 static char *genPFN(char *dst, int dln, const char *src);
61 
62 static int getCname(const char *path, char *Cache, char *lbuf=0, int lbsz=0);
63 
64 static int isXA(const char *path) {return path[strlen(path)-1] == xChar;}
65 
66 static int InitPrefix();
67 
68 enum theSfx {isBase =0, isAnew =1,
69  sfxMigF=1, isFail=2, isLock =3, isPin =4, sfxMigL=4,
71  isPfn=8, sfxLast=8, sfxNum =9
72  };
73 
74 static
75 const char *Sfx[sfxNum];
76 
77 static const int chkMem = 0x01;
78 static const int chkMig = 0x02;
79 static const int chkPfn = 0x04;
80 static const int chkAll = 0x07;
81 
82 static theSfx pathType(const char *Path, int chkWhat=chkAll);
83 
84 static void Trim2Base(char *eP);
85 
88 
89 private:
90 static char *bin2hex(char *inbuff, int dlen, char *buff);
91 static char *posCname(char *lbuf, int lbsz, int &cnsz);
92 
93 static char h2c[16];
94 static char pfnPfx[60];
95 };
96 #endif
static char * genPath(const char *inPath, const char *cgrp, char *sfx)
static char pfnPfx[60]
Definition: XrdOssPath.hh:94
static theSfx pathType(const char *Path, int chkWhat=chkAll)
const char * Sfx
Definition: XrdOssPath.hh:42
static const int sfxLen
Definition: XrdOssPath.hh:49
XrdOssPath()
Definition: XrdOssPath.hh:86
Definition: XrdOssPath.hh:70
Definition: XrdOssPath.hh:70
static int getCname(const char *path, char *Cache, char *lbuf=0, int lbsz=0)
static const int chkMem
Definition: XrdOssPath.hh:77
const char * Path
Definition: XrdOssPath.hh:41
Definition: XrdOssPath.hh:69
static int isXA(const char *path)
Definition: XrdOssPath.hh:64
static int InitPrefix()
int Plen
Definition: XrdOssPath.hh:44
Definition: XrdOssPath.hh:71
static char * genPFN(fnInfo &Info, char *buff, int blen, const char *Path=0)
Definition: XrdOssPath.hh:70
Definition: XrdOssPath.hh:70
Definition: XrdOssPath.hh:71
Definition: XrdOssPath.hh:69
static const char xChar
Definition: XrdOssPath.hh:47
Definition: XrdOssPath.hh:68
static char * bin2hex(char *inbuff, int dlen, char *buff)
static const int chkAll
Definition: XrdOssPath.hh:80
XrdCmsCache Cache
char * Slash
Definition: XrdOssPath.hh:43
static char * posCname(char *lbuf, int lbsz, int &cnsz)
static char h2c[16]
Definition: XrdOssPath.hh:93
Definition: XrdOssPath.hh:68
theSfx
Definition: XrdOssPath.hh:68
Definition: XrdOssPath.hh:69
static const char * Extract(char *path, char *lbuf, int &lbsz)
static const char * Sfx[sfxNum]
Definition: XrdOssPath.hh:75
static const int chkPfn
Definition: XrdOssPath.hh:79
Definition: XrdOssPath.hh:69
static void Trim2Base(char *eP)
Definition: XrdOssPath.hh:35
Definition: XrdOssPath.hh:70
Definition: XrdOssPath.hh:39
static int Convert(char *dst, int dln, const char *oldP, const char *newP)
Definition: XrdMacaroonsHandler.hh:18
Definition: XrdOssPath.hh:69
static const int chkMig
Definition: XrdOssPath.hh:78
Definition: XrdOssPath.hh:71
~XrdOssPath()
Definition: XrdOssPath.hh:87