Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
PHmd5Value.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file PHmd5Value.cc
1
#include <
PHmd5Value.h
>
2
3
#include <
PHmd5Utils.h
>
4
#include <iomanip>
5
6
PHmd5Value::PHmd5Value
()
7
{
8
int
i
;
9
for
(i = 0; i <
PHMD5DIGESTLENGTH
; i++)
10
theDigest
[i] = 0;
11
isNotValid
= 1;
// no value set yet.
12
13
}
14
15
PHmd5Value::PHmd5Value
(
const
PHmd5Value
&other)
16
{
17
if
( other.
getMD5
(
theDigest
) )
isNotValid
=1;
18
else
isNotValid
= 0;
19
}
20
21
PHmd5Value::PHmd5Value
(FILE *fp)
22
{
23
if
(
PHmd5Stream
(fp,
theDigest
, &
filesize
) )
isNotValid
=1;
24
else
isNotValid
= 0;
25
}
26
27
PHmd5Value::PHmd5Value
(
const
char
*
filename
)
28
{
29
if
(
PHmd5File
(filename,
theDigest
, &
filesize
) )
isNotValid
=1;
30
else
isNotValid
= 0;
31
}
32
33
PHmd5Value::~PHmd5Value
()
34
{}
35
36
int
PHmd5Value::Status
()
const
37
{
38
return
isNotValid
;
39
}
40
41
int
PHmd5Value::FileSize
()
const
42
{
43
return
filesize
;
44
}
45
46
47
int
PHmd5Value::operator==
(
const
PHmd5Value
&other)
const
48
{
49
//if either object has a bad status, we declare a non-match
50
if
(
isNotValid
|| other.
Status
() )
return
0;
51
52
unsigned
char
otherDigest[
PHMD5DIGESTLENGTH
];
53
other.
getMD5
(otherDigest);
54
int
i
;
55
for
(i = 0; i <
PHMD5DIGESTLENGTH
; i++)
56
if
(
theDigest
[i] != otherDigest[i])
return
0;
57
58
return
1;
59
}
60
61
int
PHmd5Value::getMD5
(
unsigned
char
* digest)
const
62
{
63
64
// if we weren't constructed right, don't hand out the
65
//digest
66
if
(
isNotValid
)
return
1;
67
68
int
i
;
69
for
(i = 0; i <
PHMD5DIGESTLENGTH
; i++)
70
digest[i] =
theDigest
[i];
71
72
return
0;
73
74
}
75
76
int
PHmd5Value::setMD5
(
const
unsigned
char
* digest)
77
{
78
79
int
i
;
80
for
(i = 0; i <
PHMD5DIGESTLENGTH
; i++)
81
theDigest
[i] = digest[i];
82
isNotValid
= 1;
83
return
0;
84
85
}
86
87
88
int
PHmd5Value::setFileMD5
(
const
char
*
filename
)
89
{
90
if
(
PHmd5File
(filename,
theDigest
, &
filesize
) )
isNotValid
=1;
91
else
isNotValid
= 0;
92
return
isNotValid
;
93
}
94
95
OSTREAM
&
operator<<
(
OSTREAM
&
os
,
const
PHmd5Value
&md )
96
{
97
int
i
;
98
99
// char v[2];
100
101
if
( !md.
Status
() )
102
{
103
for
(i = 0; i <
PHMD5DIGESTLENGTH
; i++)
104
{
105
// sprintf(v, "%02x", md.theDigest[i]);
106
os << std::setw(2) << std::hex << md.
theDigest
[
i
] << std::dec;
107
}
108
}
109
else
110
{
111
for
(i = 0; i <
PHMD5DIGESTLENGTH
; i++)
112
os <<
"00"
;
113
}
114
115
return
os
;
116
}
online_distribution
blob
master
newbasic
PHmd5Value.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:28
using
1.8.2 with
sPHENIX GitHub integration