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
int segSize
Definition: XrdCksLoad.hh:109
csInfo csTab[csMax]
Definition: XrdCksLoad.hh:107
virtual int Set(const char *Pfn, XrdCksData &Cks, int myTime=0)
virtual int Init(const char *ConfigFN, const char *AddCalc=0)
Definition: XrdCks.hh:91
int csLast
Definition: XrdCksLoad.hh:108
virtual char * List(const char *Pfn, char *Buff, int Blen, char Sep=' ')
int Len
Definition: XrdCksLoad.hh:98
char * Path
Definition: XrdCksLoad.hh:95
XrdCksLoader(XrdSysError *erP, int iosz, XrdVersionInfo *vInfo)
virtual int Ver(const char *Pfn, XrdCksData &Cks)
virtual int Config(const char *Token, char *Line)
static const int csMax
Definition: XrdCksLoad.hh:106
char * Parms
Definition: XrdCksLoad.hh:96
virtual int ModTime(const char *Pfn, time_t &MTime)
virtual int Calc(const char *Pfn, XrdCksData &Cks, int doSet=1)
virtual ~XrdCksLoader()
virtual int Del(const char *Pfn, XrdCksData &Cks)
Definition: XrdCksData.hh:37
Definition: XrdSysError.hh:89
Definition: XrdCksLoad.hh:92
Definition: XrdSysPlugin.hh:52
Definition: XrdCksCalc.hh:39
Definition: XrdCksLoad.hh:47
csInfo()
Definition: XrdCksLoad.hh:99
virtual int Get(const char *Pfn, XrdCksData &Cks)
virtual int Size(const char *Name=0)
virtual const char * Name(int seqNum=0)
XrdVersionInfo * myVersion
Definition: XrdCksLoad.hh:110
static const int NameSize
Definition: XrdCksData.hh:41
char Name[XrdCksData::NameSize]
Definition: XrdCksLoad.hh:93
virtual XrdCksCalc * Object(const char *name)
Definition: XrdMacaroonsHandler.hh:18
csInfo * Find(const char *Name)
XrdSysPlugin * Plugin
Definition: XrdCksLoad.hh:97
XrdCksCalc * Obj
Definition: XrdCksLoad.hh:94