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