|
xrootd
|
00001 #ifndef __XROOTD_RESPONSE_H__ 00002 #define __XROOTD_RESPONSE_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d X r o o t d R e s p o n s e . h h */ 00006 /* */ 00007 /* (c) 2004 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 <string.h> 00033 #include <unistd.h> 00034 #include <sys/uio.h> 00035 00036 #include "XProtocol/XProtocol.hh" 00037 #include "XProtocol/XPtypes.hh" 00038 #include "XrdXrootd/XrdXrootdReqID.hh" 00039 00040 /******************************************************************************/ 00041 /* x r o o t d _ R e s p o n s e */ 00042 /******************************************************************************/ 00043 00044 class XrdLink; 00045 00046 class XrdXrootdResponse 00047 { 00048 public: 00049 00050 const char *ID() {return (const char *)trsid;} 00051 00052 int Push(void *data, int dlen); 00053 int Push(void); 00054 int Send(void); 00055 int Send(const char *msg); 00056 int Send(XErrorCode ecode, const char *msg); 00057 int Send(void *data, int dlen); 00058 int Send(struct iovec *, int iovcnt, int iolen=-1); 00059 int Send(XResponseType rcode, void *data, int dlen); 00060 int Send(XResponseType rcode, int info, const char *data); 00061 int Send(int fdnum, long long offset, int dlen); 00062 static int Send(XrdXrootdReqID &ReqID, XResponseType Status, 00063 struct iovec *IOResp, int iornum, int iolen); 00064 00065 inline void Set(XrdLink *lp) {Link = lp;} 00066 void Set(kXR_char *stream); 00067 00068 XrdLink *theLink() {return Link;} 00069 void StreamID(kXR_char *sid) {sid[0] = Resp.streamid[0]; 00070 sid[1] = Resp.streamid[1]; 00071 } 00072 00073 XrdXrootdResponse(XrdXrootdResponse &rhs) {Set(rhs.Link); 00074 Set(rhs.Resp.streamid); 00075 } 00076 00077 XrdXrootdResponse() {Link = 0; *trsid = '\0'; 00078 RespIO[0].iov_base = (caddr_t)&Resp; 00079 RespIO[0].iov_len = sizeof(Resp); 00080 } 00081 ~XrdXrootdResponse() {} 00082 00083 XrdXrootdResponse &operator =(const XrdXrootdResponse &rhs) 00084 {Set(rhs.Link); 00085 Set((unsigned char *)rhs.Resp.streamid); 00086 return *this; 00087 } 00088 00089 private: 00090 00091 ServerResponseHeader Resp; 00092 XrdLink *Link; 00093 struct iovec RespIO[3]; 00094 00095 char trsid[8]; // sizeof() does not work here 00096 static const char *TraceID; 00097 }; 00098 #endif
1.7.6.1