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 
13 #include "XrdCks/XrdCks.hh"
14 #include "XrdCks/XrdCksData.hh"
15 
16 /* This class defines the checksum management interface. It may also be used
17  as the base class for a plugin. This allows you to replace selected methods
18  which may be needed for handling certain filesystems (see protected ones).
19 */
20 
21 class XrdCksCalc;
22 class XrdSysError;
23 
24 class XrdCksManager : public XrdCks
25 {
26 public:
27 virtual int Calc( const char *Pfn, XrdCksData &Cks, int doSet=1);
28 
29 virtual int Config(const char *Token, char *Line);
30 
31 virtual int Del( const char *Pfn, XrdCksData &Cks);
32 
33 virtual int Get( const char *Pfn, XrdCksData &Cks);
34 
35 virtual int Init(const char *ConfigFN, const char *AddCalc=0);
36 
37 virtual char *List(const char *Pfn, char *Buff, int Blen, char Sep=' ');
38 
39 virtual const char *Name(int seqNum=0);
40 
41 virtual int Size( const char *Name=0);
42 
43 virtual int Set( const char *Pfn, XrdCksData &Cks, int myTime=0);
44 
45 virtual int Ver( const char *Pfn, XrdCksData &Cks);
46 
47  XrdCksManager(XrdSysError *erP, int iosz=0);
48 virtual ~XrdCksManager();
49 
50 protected:
51 
52 /* Calc() returns 0 if the checksum was successfully calculated using the
53  supplied CksObj and places the file's modification time in MTime.
54  Otherwise, it returns -errno. The default implementation uses
55  open(), fstat(), mmap(), and unmap() to calculate the results.
56 */
57 virtual int Calc(const char *Pfn, time_t &MTime, XrdCksCalc *CksObj);
58 
59 /* ModTime() returns 0 and places file's modification time in MTime. Otherwise,
60  it return -errno. The default implementation uses stat().
61 */
62 virtual int ModTime(const char *Pfn, time_t &MTime);
63 
64 private:
65 
66 struct csInfo
67  {char Name[XrdCksData::NameSize];
69  char *Path;
70  char *Parms;
72  int Len;
73  csInfo() : Obj(0), Path(0), Parms(0), Plugin(0), Len(0)
74  {memset(Name, 0, sizeof(Name));}
75  };
76 
77 int Config(const char *cFN, csInfo &Info);
78 csInfo *Find(const char *Name);
79 
80 static const int csMax = 4;
82 int csLast;
83 int segSize;
84 };
85 #endif