xrootd
|
00001 #ifndef _OSS_PATH_H 00002 #define _OSS_PATH_H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d O s s P a t h . h h */ 00006 /* */ 00007 /* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 #include <string.h> 00014 00015 class XrdOssPath 00016 { 00017 public: 00018 00019 struct fnInfo 00020 { 00021 const char *Path; 00022 const char *Sfx; // Of length sfxLen! 00023 char *Slash; 00024 int Plen; 00025 }; 00026 00027 static const char xChar = '%'; 00028 00029 static const int sfxLen = 4; 00030 00031 static int Convert(char *dst, int dln, const char *oldP, const char *newP); 00032 00033 static 00034 const char *Extract(char *path, char *lbuf, int &lbsz); 00035 00036 static char *genPath(const char *inPath, const char *cgrp, char *sfx); 00037 00038 static char *genPFN(fnInfo &Info, char *buff, int blen, const char *Path=0); 00039 00040 static char *genPFN(char *dst, int dln, const char *src); 00041 00042 static int getCname(const char *path, char *Cache, char *lbuf=0, int lbsz=0); 00043 00044 static 00045 inline int isXA(const char *path) {return path[strlen(path)-1] == xChar;} 00046 00047 enum theSfx {isBase =0, isAnew =1, 00048 sfxMigF=1, isFail=2, isLock =3, isPin =4, sfxMigL=4, 00049 sfxMemF=4, isMkeep=5, isMlock=6, isMmap=7, sfxMemL=7, 00050 isPfn=8, sfxLast=8, sfxNum =9 00051 }; 00052 00053 static 00054 const char *Sfx[sfxNum]; 00055 00056 static const int chkMem = 0x01; 00057 static const int chkMig = 0x02; 00058 static const int chkPfn = 0x04; 00059 static const int chkAll = 0x07; 00060 00061 static theSfx pathType(const char *Path, int chkWhat=chkAll); 00062 00063 static void Trim2Base(char *eP); 00064 00065 XrdOssPath() {} 00066 ~XrdOssPath() {} 00067 00068 private: 00069 static char *bin2hex(char *inbuff, int dlen, char *buff); 00070 static int Init(char *pfnPfx); 00071 static char *posCname(char *lbuf, int lbsz, int &cnsz); 00072 00073 static char h2c[16]; 00074 }; 00075 #endif