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
65 inline int isXA(const char *path) {return path[strlen(path)-1] == xChar;}
66 
67 enum theSfx {isBase =0, isAnew =1,
68  sfxMigF=1, isFail=2, isLock =3, isPin =4, sfxMigL=4,
70  isPfn=8, sfxLast=8, sfxNum =9
71  };
72 
73 static
74 const char *Sfx[sfxNum];
75 
76 static const int chkMem = 0x01;
77 static const int chkMig = 0x02;
78 static const int chkPfn = 0x04;
79 static const int chkAll = 0x07;
80 
81 static theSfx pathType(const char *Path, int chkWhat=chkAll);
82 
83 static void Trim2Base(char *eP);
84 
87 
88 private:
89 static char *bin2hex(char *inbuff, int dlen, char *buff);
90 static int Init(char *pfnPfx);
91 static char *posCname(char *lbuf, int lbsz, int &cnsz);
92 
93 static char h2c[16];
94 };
95 #endif