xrootd
XrdCksXAttr.hh
Go to the documentation of this file.
00001 #ifndef __XRDCKSXATTR_HH__
00002 #define __XRDCKSXATTR_HH__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d C k s X A t t r . h h                         */
00006 /*                                                                            */
00007 /* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 #include <sys/types.h>
00014 #include <inttypes.h>
00015 #include <netinet/in.h>
00016 #include <sys/types.h>
00017 
00018 #include "XrdCks/XrdCksData.hh"
00019 #include "XrdSys/XrdSysPlatform.hh"
00020 
00021 /* XrdCksXAttr encapsulates the extended attributes needed to save a checksum.
00022 */
00023   
00024 class XrdCksXAttr
00025 {
00026 public:
00027 
00028 XrdCksData Cks;         // Check sum information
00029 
00030 /* postGet() will put fmTime and csTime in host byte order (see preSet()).
00031 */
00032        int             postGet(int Result)
00033                               {if (Result > 0)
00034                                   {Cks.fmTime = ntohll(Cks.fmTime);
00035                                    Cks.csTime = ntohl (Cks.csTime);
00036                                   }
00037                                return Result;
00038                               }
00039 
00040 /* preSet() will put fmTime and csTime in network byte order to allow the
00041             attribute to be copied to different architectures and still work.
00042 */
00043        XrdCksXAttr    *preSet(XrdCksXAttr &tmp)
00044                              {memcpy(&tmp.Cks, &Cks, sizeof(Cks));
00045                               tmp.Cks.fmTime = htonll(Cks.fmTime);
00046                               tmp.Cks.csTime = htonl (Cks.csTime);
00047                               return &tmp;
00048                              }
00049 
00050 /* Name() returns the extended attribute name for this object.
00051 */
00052        const char     *Name() {if (!(*VarName))    //01234567
00053                                   {strcpy(VarName,  "XrdCks.");
00054                                    strcpy(VarName+7, Cks.Name);
00055                                   }
00056                                return VarName;
00057                               }
00058 
00059 /* sizeGet() and sizeSet() return the actual size of the object is used.
00060 */
00061        int             sizeGet() {return sizeof(Cks);}
00062        int             sizeSet() {return sizeof(Cks);}
00063 
00064        XrdCksXAttr() {*VarName = 0;}
00065       ~XrdCksXAttr() {}
00066 
00067 private:
00068 
00069 char VarName[XrdCksData::NameSize+8];
00070 };
00071 #endif