00001 //------------------------------------------------------------------------------ 00002 // Copyright (c) 2011-2017 by European Organization for Nuclear Research (CERN) 00003 // Author: Elvin Sindrilaru <esindril@cern.ch> 00004 //------------------------------------------------------------------------------ 00005 // This file is part of the XRootD software suite. 00006 // 00007 // XRootD is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU Lesser General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // XRootD is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public License 00018 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00019 // 00020 // In applying this licence, CERN does not waive the privileges and immunities 00021 // granted to it by virtue of its status as an Intergovernmental Organization 00022 // or submit itself to any jurisdiction. 00023 //------------------------------------------------------------------------------ 00024 00025 #pragma once 00026 #include "XrdCl/XrdClDefaultEnv.hh" 00027 #include "XrdCl/XrdClPlugInInterface.hh" 00028 00029 using namespace XrdCl; 00030 00031 namespace xrdcl_proxy 00032 { 00033 //------------------------------------------------------------------------------ 00036 //------------------------------------------------------------------------------ 00037 class ProxyPrefixFile: public XrdCl::FilePlugIn 00038 { 00039 public: 00040 //---------------------------------------------------------------------------- 00042 //---------------------------------------------------------------------------- 00043 ProxyPrefixFile(); 00044 00045 //---------------------------------------------------------------------------- 00047 //---------------------------------------------------------------------------- 00048 virtual ~ProxyPrefixFile(); 00049 00050 //---------------------------------------------------------------------------- 00052 //---------------------------------------------------------------------------- 00053 virtual XRootDStatus Open(const std::string& url, 00054 OpenFlags::Flags flags, 00055 Access::Mode mode, 00056 ResponseHandler* handler, 00057 uint16_t timeout); 00058 00059 //---------------------------------------------------------------------------- 00061 //---------------------------------------------------------------------------- 00062 virtual XRootDStatus Close(ResponseHandler* handler, 00063 uint16_t timeout) 00064 { 00065 return pFile->Close(handler, timeout); 00066 } 00067 00068 //---------------------------------------------------------------------------- 00070 //---------------------------------------------------------------------------- 00071 virtual XRootDStatus Stat(bool force, 00072 ResponseHandler* handler, 00073 uint16_t timeout) 00074 { 00075 return pFile->Stat(force, handler, timeout); 00076 } 00077 00078 00079 //---------------------------------------------------------------------------- 00081 //---------------------------------------------------------------------------- 00082 virtual XRootDStatus Read(uint64_t offset, 00083 uint32_t size, 00084 void* buffer, 00085 ResponseHandler* handler, 00086 uint16_t timeout) 00087 { 00088 return pFile->Read(offset, size, buffer, handler, timeout); 00089 } 00090 00091 //---------------------------------------------------------------------------- 00093 //---------------------------------------------------------------------------- 00094 virtual XRootDStatus Write(uint64_t offset, 00095 uint32_t size, 00096 const void* buffer, 00097 ResponseHandler* handler, 00098 uint16_t timeout) 00099 { 00100 return pFile->Write(offset, size, buffer, handler, timeout); 00101 } 00102 00103 //---------------------------------------------------------------------------- 00105 //---------------------------------------------------------------------------- 00106 virtual XRootDStatus Sync(ResponseHandler* handler, 00107 uint16_t timeout) 00108 { 00109 return pFile->Sync(handler, timeout); 00110 } 00111 00112 //---------------------------------------------------------------------------- 00114 //---------------------------------------------------------------------------- 00115 virtual XRootDStatus Truncate(uint64_t size, 00116 ResponseHandler* handler, 00117 uint16_t timeout) 00118 { 00119 return pFile->Truncate(size, handler, timeout); 00120 } 00121 00122 //---------------------------------------------------------------------------- 00124 //---------------------------------------------------------------------------- 00125 virtual XRootDStatus VectorRead(const ChunkList& chunks, 00126 void* buffer, 00127 ResponseHandler* handler, 00128 uint16_t timeout) 00129 { 00130 return pFile->VectorRead(chunks, buffer, handler, timeout); 00131 } 00132 00133 //---------------------------------------------------------------------------- 00135 //---------------------------------------------------------------------------- 00136 virtual XRootDStatus Fcntl(const Buffer& arg, 00137 ResponseHandler* handler, 00138 uint16_t timeout) 00139 { 00140 return pFile->Fcntl(arg, handler, timeout); 00141 } 00142 00143 //---------------------------------------------------------------------------- 00145 //---------------------------------------------------------------------------- 00146 virtual XRootDStatus Visa(ResponseHandler* handler, 00147 uint16_t timeout) 00148 { 00149 return pFile->Visa(handler, timeout); 00150 } 00151 00152 //---------------------------------------------------------------------------- 00154 //---------------------------------------------------------------------------- 00155 virtual bool IsOpen() const 00156 { 00157 return pFile->IsOpen(); 00158 } 00159 00160 //---------------------------------------------------------------------------- 00162 //---------------------------------------------------------------------------- 00163 virtual bool SetProperty(const std::string& name, 00164 const std::string& value) 00165 { 00166 return pFile->SetProperty(name, value); 00167 } 00168 00169 //---------------------------------------------------------------------------- 00171 //---------------------------------------------------------------------------- 00172 virtual bool GetProperty(const std::string& name, 00173 std::string& value) const 00174 { 00175 return pFile->GetProperty(name, value); 00176 } 00177 00178 private: 00179 00180 //---------------------------------------------------------------------------- 00184 //---------------------------------------------------------------------------- 00185 inline std::string trim(const std::string& in) const; 00186 00187 //---------------------------------------------------------------------------- 00191 //---------------------------------------------------------------------------- 00192 inline std::string GetPrefixUrl() const; 00193 00194 //---------------------------------------------------------------------------- 00198 //---------------------------------------------------------------------------- 00199 std::list<std::string> GetExclDomains() const; 00200 00201 //---------------------------------------------------------------------------- 00208 //---------------------------------------------------------------------------- 00209 std::string ConstructFinalUrl(const std::string& orig_url) const; 00210 00211 //---------------------------------------------------------------------------- 00217 //---------------------------------------------------------------------------- 00218 std::string GetFqdn(const std::string& hostname) const; 00219 00220 bool mIsOpen; 00221 XrdCl::File* pFile; 00222 }; 00223 00224 } // namespace xrdcl_proxy