xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdCks
XrdCksXAttr.hh
Go to the documentation of this file.
1
#ifndef __XRDCKSXATTR_HH__
2
#define __XRDCKSXATTR_HH__
3
/******************************************************************************/
4
/* */
5
/* X r d C k s X A t t 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
#include <inttypes.h>
35
#include <netinet/in.h>
36
#include <sys/types.h>
37
38
#include "
XrdCks/XrdCksData.hh
"
39
#include "
XrdSys/XrdSysPlatform.hh
"
40
41
/* XrdCksXAttr encapsulates the extended attributes needed to save a checksum.
42
*/
43
44
class
XrdCksXAttr
45
{
46
public
:
47
48
XrdCksData
Cks
;
// Check sum information
49
50
/* postGet() will put fmTime and csTime in host byte order (see preSet()).
51
*/
52
int
postGet
(
int
Result)
53
{
if
(Result > 0)
54
{
Cks
.
fmTime
= ntohll(
Cks
.
fmTime
);
55
Cks
.
csTime
= ntohl (
Cks
.
csTime
);
56
}
57
return
Result;
58
}
59
60
/* preSet() will put fmTime and csTime in network byte order to allow the
61
attribute to be copied to different architectures and still work.
62
*/
63
XrdCksXAttr
*
preSet
(
XrdCksXAttr
&tmp)
64
{memcpy(&tmp.
Cks
, &
Cks
,
sizeof
(
Cks
));
65
tmp.
Cks
.
fmTime
= htonll(
Cks
.
fmTime
);
66
tmp.
Cks
.
csTime
= htonl (
Cks
.
csTime
);
67
return
&tmp;
68
}
69
70
/* Name() returns the extended attribute name for this object.
71
*/
72
const
char
*
Name
() {
if
(!(*
VarName
))
//01234567
73
{strcpy(
VarName
,
"XrdCks."
);
74
strcpy(
VarName
+7,
Cks
.
Name
);
75
}
76
return
VarName
;
77
}
78
79
/* sizeGet() and sizeSet() return the actual size of the object is used.
80
*/
81
int
sizeGet
() {
return
sizeof
(
Cks
);}
82
int
sizeSet
() {
return
sizeof
(
Cks
);}
83
84
XrdCksXAttr
() {*
VarName
= 0;}
85
~XrdCksXAttr
() {}
86
87
private
:
88
89
char
VarName
[
XrdCksData::NameSize
+8];
90
};
91
#endif
Generated by
1.8.3.1