xrootd
Loading...
Searching...
No Matches
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
43class XrdCksCalc;
44class XrdCksLoader;
45class XrdSysError;
46struct XrdVersionInfo;
47
48class XrdCksManager : public XrdCks
49{
50public:
51virtual int Calc( const char *Pfn, XrdCksData &Cks, int doSet=1);
52
53virtual int Config(const char *Token, char *Line);
54
55virtual int Del( const char *Pfn, XrdCksData &Cks);
56
57virtual int Get( const char *Pfn, XrdCksData &Cks);
58
59virtual int Init(const char *ConfigFN, const char *AddCalc=0);
60
61virtual char *List(const char *Pfn, char *Buff, int Blen, char Sep=' ');
62
63virtual const char *Name(int seqNum=0);
64
65virtual XrdCksCalc *Object(const char *name);
66
67virtual int Size( const char *Name=0);
68
69virtual int Set( const char *Pfn, XrdCksData &Cks, int myTime=0);
70
71virtual int Ver( const char *Pfn, XrdCksData &Cks);
72
73 XrdCksManager(XrdSysError *erP, int iosz,
74 XrdVersionInfo &vInfo, bool autoload=false);
76
77protected:
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*/
84virtual 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*/
89virtual int ModTime(const char *Pfn, time_t &MTime);
90
91private:
92
93struct csInfo
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
106int Config(const char *cFN, csInfo &Info);
107csInfo *Find(const char *Name);
108
109static const int csMax = 8;
114XrdVersionInfo &myVersion;
115};
116#endif
Definition XrdCksCalc.hh:40
Definition XrdCksData.hh:38
static const int NameSize
Definition XrdCksData.hh:41
Definition XrdCksLoader.hh:43
Definition XrdCksManager.hh:49
virtual int Config(const char *Token, char *Line)
virtual int Init(const char *ConfigFN, const char *AddCalc=0)
virtual int Calc(const char *Pfn, time_t &MTime, XrdCksCalc *CksObj)
csInfo csTab[csMax]
Definition XrdCksManager.hh:110
virtual int Ver(const char *Pfn, XrdCksData &Cks)
virtual XrdCksCalc * Object(const char *name)
int Config(const char *cFN, csInfo &Info)
csInfo * Find(const char *Name)
virtual int Calc(const char *Pfn, XrdCksData &Cks, int doSet=1)
virtual const char * Name(int seqNum=0)
virtual int Del(const char *Pfn, XrdCksData &Cks)
virtual char * List(const char *Pfn, char *Buff, int Blen, char Sep=' ')
int csLast
Definition XrdCksManager.hh:111
virtual int Set(const char *Pfn, XrdCksData &Cks, int myTime=0)
virtual int ModTime(const char *Pfn, time_t &MTime)
static const int csMax
Definition XrdCksManager.hh:109
int segSize
Definition XrdCksManager.hh:112
virtual ~XrdCksManager()
XrdCksLoader * cksLoader
Definition XrdCksManager.hh:113
XrdCksManager(XrdSysError *erP, int iosz, XrdVersionInfo &vInfo, bool autoload=false)
virtual int Get(const char *Pfn, XrdCksData &Cks)
XrdVersionInfo & myVersion
Definition XrdCksManager.hh:114
virtual int Size(const char *Name=0)
Definition XrdCks.hh:92
Definition XrdSysError.hh:90
Definition XrdSysPlugin.hh:53
Definition XrdCksManager.hh:94
bool doDel
Definition XrdCksManager.hh:100
csInfo()
Definition XrdCksManager.hh:101
XrdCksCalc * Obj
Definition XrdCksManager.hh:95
int Len
Definition XrdCksManager.hh:99
char * Path
Definition XrdCksManager.hh:96
char Name[XrdCksData::NameSize]
Definition XrdCksManager.hh:94
XrdSysPlugin * Plugin
Definition XrdCksManager.hh:98
char * Parms
Definition XrdCksManager.hh:97