xrootd
Loading...
Searching...
No Matches
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 <cinttypes>
34#include <netinet/in.h>
35#include <sys/types.h>
36
37#include "XrdCks/XrdCksData.hh"
39
40/* XrdCksXAttr encapsulates the extended attributes needed to save a checksum.
41*/
42
44{
45public:
46
47XrdCksData Cks; // Check sum information
48
49/* postGet() will put fmTime and csTime in host byte order (see preSet()).
50*/
51 int postGet(int Result)
52 {if (Result > 0)
53 {Cks.fmTime = ntohll(Cks.fmTime);
54 Cks.csTime = ntohl (Cks.csTime);
55 }
56 return Result;
57 }
58
59/* preSet() will put fmTime and csTime in network byte order to allow the
60 attribute to be copied to different architectures and still work.
61*/
63 {memcpy(&tmp.Cks, &Cks, sizeof(Cks));
64 tmp.Cks.fmTime = htonll(Cks.fmTime);
65 tmp.Cks.csTime = htonl (Cks.csTime);
66 return &tmp;
67 }
68
69/* Name() returns the extended attribute name for this object.
70*/
71 const char *Name() {if (!(*VarName)) //01234567
72 {strcpy(VarName, "XrdCks.");
73 strcpy(VarName+7, Cks.Name);
74 }
75 return VarName;
76 }
77
78/* sizeGet() and sizeSet() return the actual size of the object is used.
79*/
80 int sizeGet() {return sizeof(Cks);}
81 int sizeSet() {return sizeof(Cks);}
82
85
86private:
87
89};
90#endif
Definition XrdCksData.hh:38
int csTime
Definition XrdCksData.hh:49
long long fmTime
Definition XrdCksData.hh:46
static const int NameSize
Definition XrdCksData.hh:41
char Name[NameSize]
Definition XrdCksData.hh:44
Definition XrdCksXAttr.hh:44
int sizeGet()
Definition XrdCksXAttr.hh:80
XrdCksXAttr * preSet(XrdCksXAttr &tmp)
Definition XrdCksXAttr.hh:62
const char * Name()
Definition XrdCksXAttr.hh:71
XrdCksXAttr()
Definition XrdCksXAttr.hh:83
~XrdCksXAttr()
Definition XrdCksXAttr.hh:84
int sizeSet()
Definition XrdCksXAttr.hh:81
int postGet(int Result)
Definition XrdCksXAttr.hh:51
XrdCksData Cks
Definition XrdCksXAttr.hh:47
char VarName[XrdCksData::NameSize+8]
Definition XrdCksXAttr.hh:88