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 /* All Rights Reserved. See XrdInfo.cc for complete License Terms */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC03-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // $Id$ 00014 00015 #include <string.h> 00016 #include <unistd.h> 00017 #include <sys/uio.h> 00018 00019 #include "XProtocol/XProtocol.hh" 00020 #include "XProtocol/XPtypes.hh" 00021 #include "XrdXrootd/XrdXrootdReqID.hh" 00022 00023 /******************************************************************************/ 00024 /* x r o o t d _ R e s p o n s e */ 00025 /******************************************************************************/ 00026 00027 class XrdLink; 00028 00029 class XrdXrootdResponse 00030 { 00031 public: 00032 00033 const char *ID() {return (const char *)trsid;} 00034 00035 int Push(void *data, int dlen); 00036 int Push(void); 00037 int Send(void); 00038 int Send(const char *msg); 00039 int Send(XErrorCode ecode, const char *msg); 00040 int Send(void *data, int dlen); 00041 int Send(struct iovec *, int iovcnt, int iolen=-1); 00042 int Send(XResponseType rcode, void *data, int dlen); 00043 int Send(XResponseType rcode, int info, const char *data); 00044 int Send(int fdnum, long long offset, int dlen); 00045 static int Send(XrdXrootdReqID &ReqID, XResponseType Status, 00046 struct iovec *IOResp, int iornum, int iolen); 00047 00048 inline void Set(XrdLink *lp) {Link = lp;} 00049 void Set(kXR_char *stream); 00050 00051 XrdLink *theLink() {return Link;} 00052 void StreamID(kXR_char *sid) {sid[0] = Resp.streamid[0]; 00053 sid[1] = Resp.streamid[1]; 00054 } 00055 00056 XrdXrootdResponse(XrdXrootdResponse &rhs) {Set(rhs.Link); 00057 Set(rhs.Resp.streamid); 00058 } 00059 00060 XrdXrootdResponse() {Link = 0; *trsid = '\0'; 00061 RespIO[0].iov_base = (caddr_t)&Resp; 00062 RespIO[0].iov_len = sizeof(Resp); 00063 } 00064 ~XrdXrootdResponse() {} 00065 00066 XrdXrootdResponse &operator =(const XrdXrootdResponse &rhs) 00067 {Set(rhs.Link); 00068 Set((unsigned char *)rhs.Resp.streamid); 00069 return *this; 00070 } 00071 00072 private: 00073 00074 ServerResponseHeader Resp; 00075 XrdLink *Link; 00076 struct iovec RespIO[3]; 00077 00078 char trsid[8]; // sizeof() does not work here 00079 static const char *TraceID; 00080 }; 00081 #endif