Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef __XRDCKSMANAGER_HH__
0002 #define __XRDCKSMANAGER_HH__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                      X r d C k s M a n a g e r . h h                       */
0006 /*                                                                            */
0007 /* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 #include "sys/types.h"
0034 
0035 #include "XrdCks/XrdCks.hh"
0036 #include "XrdCks/XrdCksData.hh"
0037 
0038 /* This class defines the checksum management interface. It may also be used
0039    as the base class for a plugin. This allows you to replace selected methods
0040    which may be needed for handling certain filesystems (see protected ones).
0041 */
0042 
0043 class  XrdCksCalc;
0044 class  XrdCksLoader;
0045 class  XrdSysError;
0046 struct XrdVersionInfo;
0047   
0048 class XrdCksManager : public XrdCks
0049 {
0050 public:
0051 virtual int         Calc( const char *Pfn, XrdCksData &Cks, int doSet=1);
0052 
0053 virtual int         Config(const char *Token, char *Line);
0054 
0055 virtual int         Del(  const char *Pfn, XrdCksData &Cks);
0056 
0057 virtual int         Get(  const char *Pfn, XrdCksData &Cks);
0058 
0059 virtual int         Init(const char *ConfigFN, const char *AddCalc=0);
0060 
0061 virtual char       *List(const char *Pfn, char *Buff, int Blen, char Sep=' ');
0062 
0063 virtual const char *Name(int seqNum=0);
0064 
0065 virtual XrdCksCalc *Object(const char *name);
0066 
0067 virtual int         Size( const char  *Name=0);
0068 
0069 virtual int         Set(  const char *Pfn, XrdCksData &Cks, int myTime=0);
0070 
0071 // Valid options and the values, The high order bit must be zero
0072 //
0073         enum {Cks_nomtchk = 0x00000001};
0074 
0075         void        SetOpts(int opt);
0076 
0077 virtual int         Ver(  const char *Pfn, XrdCksData &Cks);
0078 
0079                     XrdCksManager(XrdSysError *erP, int iosz,
0080                                   XrdVersionInfo &vInfo, bool autoload=false);
0081 virtual            ~XrdCksManager();
0082 
0083 protected:
0084 
0085 /* Calc()     returns 0 if the checksum was successfully calculated using the
0086               supplied CksObj and places the file's modification time in MTime.
0087               Otherwise, it returns -errno. The default implementation uses
0088               open(), fstat(), mmap(), and unmap() to calculate the results.
0089 */
0090 virtual int         Calc(const char *Pfn, time_t &MTime, XrdCksCalc *CksObj);
0091 
0092 /* ModTime()  returns 0 and places file's modification time in MTime. Otherwise,
0093               it return -errno. The default implementation uses stat().
0094 */
0095 virtual int         ModTime(const char *Pfn, time_t &MTime);
0096 
0097 private:
0098 
0099 using XrdCks::Calc;
0100 
0101 struct csInfo
0102       {char          Name[XrdCksData::NameSize];
0103        XrdCksCalc   *Obj;
0104        char         *Path;
0105        char         *Parms;
0106        XrdSysPlugin *Plugin;
0107        int           Len;
0108        bool          doDel;
0109                      csInfo() : Obj(0), Path(0), Parms(0), Plugin(0), Len(0),
0110                                 doDel(true)
0111                                 {memset(Name, 0, sizeof(Name));}
0112       };
0113 
0114 int     Config(const char *cFN, csInfo &Info);
0115 csInfo *Find(const char *Name);
0116 
0117 static const int csMax = 8;
0118 csInfo           csTab[csMax];
0119 int              csLast;
0120 int              segSize;
0121 XrdCksLoader    *cksLoader;
0122 XrdVersionInfo  &myVersion;
0123 };
0124 #endif