00001 #ifndef __XRDXMLMETALINK_HH__ 00002 #define __XRDXMLMETALINK_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d X m l M e t a L i n k . h h */ 00006 /* */ 00007 /* (c) 2015 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00010 /* */ 00011 /* This file is part of the XRootD software suite. */ 00012 /* */ 00013 /* XRootD is free software: you can redistribute it and/or modify it under */ 00014 /* the terms of the GNU Lesser General Public License as published by the */ 00015 /* Free Software Foundation, either version 3 of the License, or (at your */ 00016 /* option) any later version. */ 00017 /* */ 00018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00021 /* License for more details. */ 00022 /* */ 00023 /* You should have received a copy of the GNU Lesser General Public License */ 00024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00026 /* */ 00027 /* The copyright holder's institutional names and contributor's names may not */ 00028 /* be used to endorse or promote products derived from this software without */ 00029 /* specific prior written permission of the institution or contributor. */ 00030 /******************************************************************************/ 00031 00032 #include <stdlib.h> 00033 #include <string.h> 00034 00035 #include "XrdOuc/XrdOucFileInfo.hh" 00036 #include "XrdXml/XrdXmlReader.hh" 00037 00038 //----------------------------------------------------------------------------- 00044 //----------------------------------------------------------------------------- 00045 00046 class XrdXmlMetaLink 00047 { 00048 public: 00049 00050 //----------------------------------------------------------------------------- 00067 //----------------------------------------------------------------------------- 00068 00069 XrdOucFileInfo *Convert(const char *fbuff, int blen=0); 00070 00071 //----------------------------------------------------------------------------- 00092 //----------------------------------------------------------------------------- 00093 00094 XrdOucFileInfo **ConvertAll(const char *fbuff, int &count, int blen=0); 00095 00096 //----------------------------------------------------------------------------- 00101 //----------------------------------------------------------------------------- 00102 00103 static void DeleteAll(XrdOucFileInfo **vecp, int vecn); 00104 00105 //----------------------------------------------------------------------------- 00113 //----------------------------------------------------------------------------- 00114 00115 const char *GetStatus(int &ecode) {ecode = eCode; return eText;} 00116 00117 //----------------------------------------------------------------------------- 00134 //----------------------------------------------------------------------------- 00135 00136 XrdXmlMetaLink(const char *protos="root:xroot:", 00137 const char *rdprot="xroot:", 00138 const char *rdhost=0, 00139 const char *encode=0 00140 ) : reader(0), 00141 fileList(0), lastFile(0), currFile(0), 00142 prots(protos ? strdup(protos) : 0), 00143 encType(encode ? strdup(encode) : 0), 00144 rdProt(rdprot), rdHost(rdhost), 00145 fileCnt(0), eCode(0), 00146 doAll(false), noUrl(true) 00147 {*eText = 0; *tmpFn = 0;} 00148 00149 //----------------------------------------------------------------------------- 00151 //----------------------------------------------------------------------------- 00152 00153 ~XrdXmlMetaLink() {if (prots) free(prots); 00154 if (encType) free(encType); 00155 } 00156 00157 private: 00158 bool GetFile(const char *scope); 00159 bool GetFileInfo(const char *scope); 00160 bool GetGLfn(); 00161 bool GetHash(); 00162 void GetRdrError(const char *why); 00163 bool GetSize(); 00164 bool GetUrl(); 00165 void GetName(); 00166 bool PutFile(const char *buff, int blen); 00167 bool UrlOK(char *url); 00168 00169 XrdXmlReader *reader; 00170 XrdOucFileInfo *fileList; 00171 XrdOucFileInfo *lastFile; 00172 XrdOucFileInfo *currFile; 00173 char *prots; 00174 char *encType; 00175 const char *rdProt; 00176 const char *rdHost; 00177 int fileCnt; 00178 int eCode; 00179 bool doAll; 00180 bool noUrl; 00181 char tmpFn[64]; 00182 char eText[256]; 00183 }; 00184 #endif