|
xrootd
|
00001 #ifndef __SUT_BUFFER_H__ 00002 #define __SUT_BUFFER_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S u t B u f f e r . h h */ 00006 /* */ 00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* Produced by Geri Ganis for CERN */ 00009 /* */ 00010 /* This file is part of the XRootD software suite. */ 00011 /* */ 00012 /* XRootD is free software: you can redistribute it and/or modify it under */ 00013 /* the terms of the GNU Lesser General Public License as published by the */ 00014 /* Free Software Foundation, either version 3 of the License, or (at your */ 00015 /* option) any later version. */ 00016 /* */ 00017 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00018 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00019 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00020 /* License for more details. */ 00021 /* */ 00022 /* You should have received a copy of the GNU Lesser General Public License */ 00023 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00024 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00025 /* */ 00026 /* The copyright holder's institutional names and contributor's names may not */ 00027 /* be used to endorse or promote products derived from this software without */ 00028 /* specific prior written permission of the institution or contributor. */ 00029 /******************************************************************************/ 00030 00031 #ifndef __SUT_BUCKLIST_H__ 00032 #include "XrdSut/XrdSutBuckList.hh" 00033 #endif 00034 00035 /******************************************************************************/ 00036 /* */ 00037 /* Buffer structure for managing exchanged buckets */ 00038 /* */ 00039 /******************************************************************************/ 00040 00041 class XrdOucString; 00042 00043 class XrdSutBuffer { 00044 00045 private: 00046 00047 XrdSutBuckList fBuckets; 00048 XrdOucString fOptions; 00049 XrdOucString fProtocol; 00050 kXR_int32 fStep; 00051 00052 public: 00053 XrdSutBuffer(const char *prot, const char *opts = 0) 00054 {fOptions = opts; fProtocol = prot; fStep = 0;} 00055 XrdSutBuffer(const char *buffer, kXR_int32 length); 00056 00057 virtual ~XrdSutBuffer(); 00058 00059 int AddBucket(char *bp=0, int sz=0, int ty=0) 00060 { XrdSutBucket *b = new XrdSutBucket(bp,sz,ty); 00061 if (b) { fBuckets.PushBack(b); return 0;} return -1; } 00062 int AddBucket(XrdOucString s, int ty=0) 00063 { XrdSutBucket *b = new XrdSutBucket(s,ty); 00064 if (b) { fBuckets.PushBack(b); return 0;} return -1; } 00065 int AddBucket(XrdSutBucket *b) 00066 { if (b) { fBuckets.PushBack(b); return 0;} return -1; } 00067 00068 int UpdateBucket(const char *bp, int sz, int ty); 00069 int UpdateBucket(XrdOucString s, int ty); 00070 00071 // Remove from the list, to avoid destroy by ~XrdSutBuffer 00072 void Remove(XrdSutBucket *b) { fBuckets.Remove(b); } 00073 00074 void Dump(const char *stepstr = 0); 00075 void Message(const char *prepose = 0); 00076 int Serialized(char **buffer, char opt = 'n'); 00077 00078 void Deactivate(kXR_int32 type); // Deactivate bucket (type=-1 for cleanup) 00079 00080 // To fill / access buckets containing 4-byte integers (status codes, versions ...) 00081 kXR_int32 MarshalBucket(kXR_int32 type, kXR_int32 code); 00082 kXR_int32 UnmarshalBucket(kXR_int32 type, kXR_int32 &code); 00083 00084 XrdSutBucket *GetBucket(kXR_int32 type, const char *tag = 0); 00085 XrdSutBuckList *GetBuckList() const { return (XrdSutBuckList *)&fBuckets; } 00086 int GetNBuckets() const { return fBuckets.Size(); } 00087 const char *GetOptions() const { return fOptions.c_str(); } 00088 const char *GetProtocol() const { return fProtocol.c_str(); } 00089 int GetStep() const { return (int)fStep; } 00090 void SetStep(int s) { fStep = (kXR_int32)s; } 00091 void IncrementStep() { fStep++; } 00092 }; 00093 00094 #endif 00095
1.7.6.1