-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathJenkinsHash.bt
42 lines (37 loc) · 841 Bytes
/
JenkinsHash.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//Jenkins Hash from Strings
uint fn_Jenkins_Hash(string s)
{
if (Strlen(s) == 0)
return 0;
local int hash = 0;
local int len = Strlen(s);
local int i;
for (i = 0; i < len; i++)
{
hash += s[i];
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return (unsigned int)hash;
}
typedef struct
{
string name<name="Name">;
local uint hash = fn_Jenkins_Hash(name);
} myString_t <name="String", read=fn_Read_Hash>;
string fn_Read_Hash(myString_t &str)
{
string s;
SPrintf(s, "%s|%u", str.name, str.hash);
return s;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
LittleEndian();
while(!FEof())
{
myString_t material<name="Material">;
}