00001 #ifndef XRD_ABSCLIENTBASE_H 00002 #define XRD_ABSCLIENTBASE_H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C l i e n t A b s . h h */ 00006 /* */ 00007 /* Author: Fabrizio Furano (INFN Padova, 2004) */ 00008 /* Adapted from TXNetFile (root.cern.ch) originally done by */ 00009 /* Alvise Dorigo, Fabrizio Furano */ 00010 /* INFN Padova, 2003 */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00034 // // 00035 // Base class for objects handling redirections keeping open files // 00036 // // 00038 00039 #include <string.h> 00040 00041 #include "XrdClient/XrdClientUnsolMsg.hh" 00042 #include "XrdClient/XrdClientUrlInfo.hh" 00043 00044 #include "XProtocol/XPtypes.hh" 00045 00046 class XrdClientCallback; 00047 class XrdClientConn; 00048 00049 class XrdClientAbs: public XrdClientAbsUnsolMsgHandler { 00050 00051 // Do NOT abuse of this 00052 friend class XrdClientConn; 00053 00054 00055 protected: 00056 XrdClientConn* fConnModule; 00057 00058 char fHandle[4]; // The file handle returned by the server, 00059 // to be used for successive requests 00060 00061 00062 XrdClientCallback* fXrdCcb; 00063 void * fXrdCcbArg; 00064 00065 // After a redirection the file must be reopened. 00066 virtual bool OpenFileWhenRedirected(char *newfhandle, 00067 bool &wasopen) = 0; 00068 00069 // In some error circumstances (e.g. when writing) 00070 // a redirection on error must be denied 00071 virtual bool CanRedirOnError() = 0; 00072 00073 public: 00074 00075 XrdClientAbs(XrdClientCallback *XrdCcb = 0, void *XrdCcbArg = 0) { 00076 memset( fHandle, 0, sizeof(fHandle) ); 00077 00078 // Set the callback object, if any 00079 fXrdCcb = XrdCcb; 00080 fXrdCcbArg = XrdCcbArg; 00081 } 00082 00083 virtual bool IsOpen_wait() { 00084 return true; 00085 }; 00086 00087 void SetParm(const char *parm, int val); 00088 void SetParm(const char *parm, double val); 00089 00090 // Hook to the open connection (needed by TXNetFile) 00091 XrdClientConn *GetClientConn() const { return fConnModule; } 00092 00093 XrdClientUrlInfo GetCurrentUrl(); 00094 00095 // The last response got from a non-async request 00096 struct ServerResponseHeader *LastServerResp(); 00097 00098 struct ServerResponseBody_Error *LastServerError(); 00099 00100 // Asks for the value of some parameter 00101 //--------------------------------------------------------------------------- 00106 //--------------------------------------------------------------------------- 00107 bool Query(kXR_int16 ReqCode, const kXR_char *Args, kXR_char *Resp, kXR_int32 MaxResplen); 00108 00109 //--------------------------------------------------------------------------- 00116 //--------------------------------------------------------------------------- 00117 bool Query( kXR_int16 ReqCode, const kXR_char *Args, kXR_char **Resp, kXR_int32 MaxResplen ); 00118 00119 }; 00120 #endif