xrootd
XrdXrootdResponse.hh
Go to the documentation of this file.
1 #ifndef __XROOTD_RESPONSE_H__
2 #define __XROOTD_RESPONSE_H__
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d R e s p o n s e . h h */
6 /* */
7 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved. See XrdInfo.cc for complete License Terms */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC03-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 // $Id$
14 
15 #include <string.h>
16 #include <unistd.h>
17 #include <sys/uio.h>
18 
19 #include "XProtocol/XProtocol.hh"
20 #include "XProtocol/XPtypes.hh"
22 
23 /******************************************************************************/
24 /* x r o o t d _ R e s p o n s e */
25 /******************************************************************************/
26 
27 class XrdLink;
28 
30 {
31 public:
32 
33 const char *ID() {return (const char *)trsid;}
34 
35  int Push(void *data, int dlen);
36  int Push(void);
37  int Send(void);
38  int Send(const char *msg);
39  int Send(XErrorCode ecode, const char *msg);
40  int Send(void *data, int dlen);
41  int Send(struct iovec *, int iovcnt, int iolen=-1);
42  int Send(XResponseType rcode, void *data, int dlen);
43  int Send(XResponseType rcode, int info, const char *data);
44  int Send(int fdnum, long long offset, int dlen);
45 static int Send(XrdXrootdReqID &ReqID, XResponseType Status,
46  struct iovec *IOResp, int iornum, int iolen);
47 
48 inline void Set(XrdLink *lp) {Link = lp;}
49  void Set(kXR_char *stream);
50 
51  XrdLink *theLink() {return Link;}
52  void StreamID(kXR_char *sid) {sid[0] = Resp.streamid[0];
53  sid[1] = Resp.streamid[1];
54  }
55 
57  Set(rhs.Resp.streamid);
58  }
59 
60  XrdXrootdResponse() {Link = 0; *trsid = '\0';
61  RespIO[0].iov_base = (caddr_t)&Resp;
62  RespIO[0].iov_len = sizeof(Resp);
63  }
65 
67  {Set(rhs.Link);
68  Set((unsigned char *)rhs.Resp.streamid);
69  return *this;
70  }
71 
72 private:
73 
76 struct iovec RespIO[3];
77 
78  char trsid[8]; // sizeof() does not work here
79 static const char *TraceID;
80 };
81 #endif