xrootd
XrdCksManager.hh
Go to the documentation of this file.
1 #ifndef __XRDCKSMANAGER_HH__
2 #define __XRDCKSMANAGER_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d C k s M a n a g e r . h h */
6 /* */
7 /* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include "sys/types.h"
34 
35 #include "XrdCks/XrdCks.hh"
36 #include "XrdCks/XrdCksData.hh"
37 
38 /* This class defines the checksum management interface. It may also be used
39  as the base class for a plugin. This allows you to replace selected methods
40  which may be needed for handling certain filesystems (see protected ones).
41 */
42 
43 class XrdCksCalc;
44 class XrdCksLoader;
45 class XrdSysError;
46 struct XrdVersionInfo;
47 
48 class XrdCksManager : public XrdCks
49 {
50 public:
51 virtual int Calc( const char *Pfn, XrdCksData &Cks, int doSet=1);
52 
53 virtual int Config(const char *Token, char *Line);
54 
55 virtual int Del( const char *Pfn, XrdCksData &Cks);
56 
57 virtual int Get( const char *Pfn, XrdCksData &Cks);
58 
59 virtual int Init(const char *ConfigFN, const char *AddCalc=0);
60 
61 virtual char *List(const char *Pfn, char *Buff, int Blen, char Sep=' ');
62 
63 virtual const char *Name(int seqNum=0);
64 
65 virtual XrdCksCalc *Object(const char *name);
66 
67 virtual int Size( const char *Name=0);
68 
69 virtual int Set( const char *Pfn, XrdCksData &Cks, int myTime=0);
70 
71 virtual int Ver( const char *Pfn, XrdCksData &Cks);
72 
73  XrdCksManager(XrdSysError *erP, int iosz,
74  XrdVersionInfo &vInfo, bool autoload=false);
75 virtual ~XrdCksManager();
76 
77 protected:
78 
79 /* Calc() returns 0 if the checksum was successfully calculated using the
80  supplied CksObj and places the file's modification time in MTime.
81  Otherwise, it returns -errno. The default implementation uses
82  open(), fstat(), mmap(), and unmap() to calculate the results.
83 */
84 virtual int Calc(const char *Pfn, time_t &MTime, XrdCksCalc *CksObj);
85 
86 /* ModTime() returns 0 and places file's modification time in MTime. Otherwise,
87  it return -errno. The default implementation uses stat().
88 */
89 virtual int ModTime(const char *Pfn, time_t &MTime);
90 
91 private:
92 
93 struct csInfo
94  {char Name[XrdCksData::NameSize];
96  char *Path;
97  char *Parms;
99  int Len;
100  bool doDel;
101  csInfo() : Obj(0), Path(0), Parms(0), Plugin(0), Len(0),
102  doDel(true)
103  {memset(Name, 0, sizeof(Name));}
104  };
105 
106 int Config(const char *cFN, csInfo &Info);
107 csInfo *Find(const char *Name);
108 
109 static const int csMax = 8;
111 int csLast;
113 XrdCksLoader *cksLoader;
114 XrdVersionInfo &myVersion;
115 };
116 #endif
csInfo()
Definition: XrdCksManager.hh:101
virtual int Config(const char *Token, char *Line)
Definition: XrdCksManager.hh:48
XrdCksLoader * cksLoader
Definition: XrdCksManager.hh:113
char * Path
Definition: XrdCksManager.hh:96
Definition: XrdCks.hh:48
virtual const char * Name(int seqNum=0)
virtual int Init(const char *ConfigFN, const char *AddCalc=0)
virtual int ModTime(const char *Pfn, time_t &MTime)
virtual int Ver(const char *Pfn, XrdCksData &Cks)
virtual XrdCksCalc * Object(const char *name)
XrdSysPlugin * Plugin
Definition: XrdCksManager.hh:98
virtual int Set(const char *Pfn, XrdCksData &Cks, int myTime=0)
Definition: XrdCksData.hh:35
Definition: XrdSysError.hh:89
Definition: XrdSysPlugin.hh:52
int segSize
Definition: XrdCksManager.hh:112
Definition: XrdCksCalc.hh:39
csInfo * Find(const char *Name)
csInfo csTab[csMax]
Definition: XrdCksManager.hh:110
virtual int Calc(const char *Pfn, XrdCksData &Cks, int doSet=1)
virtual int Del(const char *Pfn, XrdCksData &Cks)
static const int csMax
Definition: XrdCksManager.hh:109
bool doDel
Definition: XrdCksManager.hh:100
XrdCksCalc * Obj
Definition: XrdCksManager.hh:95
Definition: XrdCksManager.hh:93
virtual int Size(const char *Name=0)
virtual ~XrdCksManager()
int Len
Definition: XrdCksManager.hh:99
virtual int Get(const char *Pfn, XrdCksData &Cks)
static const int NameSize
Definition: XrdCksData.hh:39
char * Parms
Definition: XrdCksManager.hh:97
XrdVersionInfo & myVersion
Definition: XrdCksManager.hh:114
XrdCksManager(XrdSysError *erP, int iosz, XrdVersionInfo &vInfo, bool autoload=false)
int csLast
Definition: XrdCksManager.hh:111
virtual char * List(const char *Pfn, char *Buff, int Blen, char Sep=' ')