Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-08 10:33:34

0001 #ifndef __XRDSSIRESPINFO_HH__
0002 #define __XRDSSIRESPINFO_HH__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                     X r d S s i R e s p I n f o . h h                      */
0006 /*                                                                            */
0007 /* (c) 2014 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0009 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0010 /*                                                                            */
0011 /* This file is part of the XRootD software suite.                            */
0012 /*                                                                            */
0013 /* XRootD is free software: you can redistribute it and/or modify it under    */
0014 /* the terms of the GNU Lesser General Public License as published by the     */
0015 /* Free Software Foundation, either version 3 of the License, or (at your     */
0016 /* option) any later version.                                                 */
0017 /*                                                                            */
0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0020 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0021 /* License for more details.                                                  */
0022 /*                                                                            */
0023 /* You should have received a copy of the GNU Lesser General Public License   */
0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0025 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0026 /*                                                                            */
0027 /* The copyright holder's institutional names and contributor's names may not */
0028 /* be used to endorse or promote products derived from this software without  */
0029 /* specific prior written permission of the institution or contributor.       */
0030 /******************************************************************************/
0031 
0032 //-----------------------------------------------------------------------------
0033 //! The RespInfo structure describes the response to be posted to a request.
0034 //! It is used mainly server-side via the inherited XrdSsiResponder class (see
0035 //! XrdSsiResponder::SetResponse). It generally hidden on the client-side since
0036 //! many of the response types valid server-side are converted to simpler
0037 //! responses client-side and requiring a client to fully deal with this struct
0038 //! is largely over-kill and unnecessary.
0039 //-----------------------------------------------------------------------------
0040 
0041 class XrdSsiStream;
0042 
0043 struct  XrdSsiRespInfo
0044        {union {const char   *buff;    //!< ->buffer     when rType == isData
0045                                       //!< ->buffer     when rType == isHandle
0046                const char   *eMsg;    //!< ->msg text   when rType == isError
0047                long long     fsize;   //!< ->file size  when rType == isFile
0048                XrdSsiStream *strmP;   //!< ->SsiStream  when rType == isStream
0049               };
0050         union {      int     blen;    //!<   buffer len When rType == isData
0051                                       //!<   buffer len When rType == isHandle
0052                      int     eNum;    //!<   errno      When rType == isError
0053                      int     fdnum;   //!<   filedesc   When rType == isFile
0054               };
0055                      int     mdlen;   //!<    Metadata length
0056                const char   *mdata;   //!< -> Metadata about response.
0057 
0058         enum   Resp_t {isNone = 0, isData, isError, isFile, isStream, isHandle};
0059         Resp_t rType;
0060 
0061         inline void  Init() {fsize=0; blen=0; mdlen=0; mdata=0; rType=isNone;}
0062 
0063         const  char *State() const {if (rType == isData  ) return "isData";
0064                                     if (rType == isError ) return "isError";
0065                                     if (rType == isHandle) return "isHandle";
0066                                     if (rType == isFile  ) return "isFile";
0067                                     if (rType == isStream) return "isStream";
0068                                     if (rType == isNone  ) return "isNone";
0069                                     return "isUndef";
0070                                    }
0071 
0072         XrdSsiRespInfo() {Init();}
0073        ~XrdSsiRespInfo() {}
0074        };
0075 
0076 /******************************************************************************/
0077 /*                         X r d S s i R e s p M s g                          */
0078 /******************************************************************************/
0079   
0080 //-----------------------------------------------------------------------------
0081 //! The RespInfoMsg class describes an async response message sent to the
0082 //! XrdSsiRequest::Alert() method. It encapsulates the message sent and must
0083 //! recover any resources used by the message when RecycleMsg() is called.
0084 //-----------------------------------------------------------------------------
0085 
0086 class XrdSsiRespInfoMsg
0087 {
0088 public:
0089 
0090 //-----------------------------------------------------------------------------
0091 //! Obtain the message associated with the message object.
0092 //!
0093 //! @param  mlen  holds the length of the message after the call.
0094 //!
0095 //! @return =0    No message available, dlen has been set to zero.
0096 //! @return !0    Pointer to the buffer holding the message, dlen has the length
0097 //-----------------------------------------------------------------------------
0098 
0099 inline  char    *GetMsg(int &mlen) {mlen = msgLen; return msgBuf;}
0100 
0101 //-----------------------------------------------------------------------------
0102 //! Release resources used by the message. This method must be called after the
0103 //! message is processed by the XrdSsiRequest::Alert() method.
0104 //!
0105 //! @param  sent  When true, the message was sent. Otherwise, it was not sent.
0106 //-----------------------------------------------------------------------------
0107 
0108 virtual void     RecycleMsg(bool sent=true) = 0;
0109 
0110 //-----------------------------------------------------------------------------
0111 //! Contructor
0112 //!
0113 //! @param  msgP  Pointer to the message buffer.
0114 //! @param  mlen  length of the message.
0115 //-----------------------------------------------------------------------------
0116 
0117                  XrdSsiRespInfoMsg(char *msgP, int mlen)
0118                                   : msgBuf(msgP), msgLen(mlen) {}
0119 
0120 protected:
0121 
0122 //-----------------------------------------------------------------------------
0123 //! Destructor. This object may not be deleted. Use Recycle() instead.
0124 //-----------------------------------------------------------------------------
0125 
0126 virtual         ~XrdSsiRespInfoMsg() {}
0127 
0128 char            *msgBuf;
0129 int              msgLen;
0130 };
0131 #endif