xrootd
XrdCksLoad.hh
Go to the documentation of this file.
1#ifndef __XRDCKSLOADER_HH__
2#define __XRDCKSLOADER_HH__
3/******************************************************************************/
4/* */
5/* X r d C k s L o a d e r . h h */
6/* */
7/* (c) 2012 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 loader interface. It is intended to be used
39 by xrootd clients to obtain an instance of a checksum calculation object.
40 This object may be builtin or may come from a shared library.
41*/
42
43class XrdCksCalc;
44class XrdSysError;
45struct XrdVersionInfo;
46
47class XrdCksLoader : public XrdCks
48{
49public:
50virtual int Calc( const char *Pfn, XrdCksData &Cks, int doSet=1);
51
52virtual int Config(const char *Token, char *Line);
53
54virtual int Del( const char *Pfn, XrdCksData &Cks);
55
56virtual int Get( const char *Pfn, XrdCksData &Cks);
57
58virtual int Init(const char *ConfigFN, const char *AddCalc=0);
59
60virtual char *List(const char *Pfn, char *Buff, int Blen, char Sep=' ');
61
62virtual const char *Name(int seqNum=0);
63
64virtual XrdCksCalc *Object(const char *name);
65
66virtual int Size( const char *Name=0);
67
68virtual int Set( const char *Pfn, XrdCksData &Cks, int myTime=0);
69
70virtual int Ver( const char *Pfn, XrdCksData &Cks);
71
72 XrdCksLoader(XrdSysError *erP, int iosz,
73 XrdVersionInfo *vInfo);
74virtual ~XrdCksLoader();
75
76protected:
77
78/* Calc() returns 0 if the checksum was successfully calculated using the
79 supplied CksObj and places the file's modification time in MTime.
80 Otherwise, it returns -errno. The default implementation uses
81 open(), fstat(), mmap(), and unmap() to calculate the results.
82*/
83virtual int Calc(const char *Pfn, time_t &MTime, XrdCksCalc *CksObj);
84
85/* ModTime() returns 0 and places file's modification time in MTime. Otherwise,
86 it return -errno. The default implementation uses stat().
87*/
88virtual int ModTime(const char *Pfn, time_t &MTime);
89
90private:
91
92struct csInfo
95 char *Path;
96 char *Parms;
98 int Len;
99 csInfo() : Obj(0), Path(0), Parms(0), Plugin(0), Len(0)
100 {memset(Name, 0, sizeof(Name));}
101 };
102
103int Config(const char *cFN, csInfo &Info);
104csInfo *Find(const char *Name);
105
106static const int csMax = 4;
110XrdVersionInfo *myVersion;
111};
112#endif
#define Info(lvl, where, what)
Definition: XrdClientDebug.hh:52
Definition: XrdCksCalc.hh:40
Definition: XrdCksData.hh:38
static const int NameSize
Definition: XrdCksData.hh:41
Definition: XrdCksLoad.hh:48
virtual XrdCksCalc * Object(const char *name)
virtual int Ver(const char *Pfn, XrdCksData &Cks)
virtual char * List(const char *Pfn, char *Buff, int Blen, char Sep=' ')
csInfo csTab[csMax]
Definition: XrdCksLoad.hh:107
virtual int Calc(const char *Pfn, XrdCksData &Cks, int doSet=1)
virtual int Config(const char *Token, char *Line)
int segSize
Definition: XrdCksLoad.hh:109
int csLast
Definition: XrdCksLoad.hh:108
static const int csMax
Definition: XrdCksLoad.hh:106
int Config(const char *cFN, csInfo &Info)
virtual const char * Name(int seqNum=0)
csInfo * Find(const char *Name)
virtual ~XrdCksLoader()
virtual int ModTime(const char *Pfn, time_t &MTime)
XrdCksLoader(XrdSysError *erP, int iosz, XrdVersionInfo *vInfo)
virtual int Del(const char *Pfn, XrdCksData &Cks)
virtual int Get(const char *Pfn, XrdCksData &Cks)
virtual int Size(const char *Name=0)
virtual int Set(const char *Pfn, XrdCksData &Cks, int myTime=0)
virtual int Calc(const char *Pfn, time_t &MTime, XrdCksCalc *CksObj)
XrdVersionInfo * myVersion
Definition: XrdCksLoad.hh:110
virtual int Init(const char *ConfigFN, const char *AddCalc=0)
Definition: XrdCks.hh:49
Definition: XrdSysError.hh:90
Definition: XrdSysPlugin.hh:53
Definition: XrdCksLoad.hh:93
XrdCksCalc * Obj
Definition: XrdCksLoad.hh:94
XrdSysPlugin * Plugin
Definition: XrdCksLoad.hh:97
char * Path
Definition: XrdCksLoad.hh:95
char * Parms
Definition: XrdCksLoad.hh:96
csInfo()
Definition: XrdCksLoad.hh:99
char Name[XrdCksData::NameSize]
Definition: XrdCksLoad.hh:93
int Len
Definition: XrdCksLoad.hh:98