line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODULE = CryptX PACKAGE = Crypt::Checksum::CRC32 |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Crypt::Checksum::CRC32 |
6
|
|
|
|
|
|
|
new(Class) |
7
|
|
|
|
|
|
|
CODE: |
8
|
|
|
|
|
|
|
{ |
9
|
8
|
|
|
|
|
|
Newz(0, RETVAL, 1, crc32_state); |
10
|
8
|
50
|
|
|
|
|
if (!RETVAL) croak("FATAL: Newz failed"); |
11
|
8
|
|
|
|
|
|
crc32_init(RETVAL); /* returns void */ |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
OUTPUT: |
14
|
|
|
|
|
|
|
RETVAL |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
void |
17
|
|
|
|
|
|
|
DESTROY(Crypt::Checksum::CRC32 self) |
18
|
|
|
|
|
|
|
CODE: |
19
|
8
|
|
|
|
|
|
Safefree(self); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
void |
22
|
|
|
|
|
|
|
reset(Crypt::Checksum::CRC32 self) |
23
|
|
|
|
|
|
|
PPCODE: |
24
|
|
|
|
|
|
|
{ |
25
|
5
|
|
|
|
|
|
crc32_init(self); /* returns void */ |
26
|
5
|
50
|
|
|
|
|
XPUSHs(ST(0)); /* return self */ |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Crypt::Checksum::CRC32 |
30
|
|
|
|
|
|
|
clone(Crypt::Checksum::CRC32 self) |
31
|
|
|
|
|
|
|
CODE: |
32
|
0
|
|
|
|
|
|
Newz(0, RETVAL, 1, crc32_state); |
33
|
0
|
0
|
|
|
|
|
if (!RETVAL) croak("FATAL: Newz failed"); |
34
|
0
|
|
|
|
|
|
Copy(self, RETVAL, 1, crc32_state); |
35
|
|
|
|
|
|
|
OUTPUT: |
36
|
|
|
|
|
|
|
RETVAL |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
void |
39
|
|
|
|
|
|
|
add(Crypt::Checksum::CRC32 self, ...) |
40
|
|
|
|
|
|
|
PPCODE: |
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
STRLEN inlen; |
43
|
|
|
|
|
|
|
int i; |
44
|
|
|
|
|
|
|
unsigned char *in; |
45
|
29
|
100
|
|
|
|
|
for(i=1; i
|
46
|
15
|
50
|
|
|
|
|
in = (unsigned char *)SvPVbyte(ST(i), inlen); |
47
|
15
|
50
|
|
|
|
|
if (inlen > 0) { |
48
|
15
|
|
|
|
|
|
crc32_update(self, in, (unsigned long)inlen); /* returns void */ |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
14
|
50
|
|
|
|
|
XPUSHs(ST(0)); /* return self */ |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
SV * |
55
|
|
|
|
|
|
|
digest(Crypt::Checksum::CRC32 self) |
56
|
|
|
|
|
|
|
ALIAS: |
57
|
|
|
|
|
|
|
hexdigest = 1 |
58
|
|
|
|
|
|
|
intdigest = 2 |
59
|
|
|
|
|
|
|
CODE: |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
int rv; |
62
|
|
|
|
|
|
|
unsigned char hash[4]; |
63
|
|
|
|
|
|
|
char out[9]; |
64
|
17
|
|
|
|
|
|
unsigned long outlen = 9; |
65
|
|
|
|
|
|
|
unsigned int ui32; |
66
|
|
|
|
|
|
|
|
67
|
17
|
|
|
|
|
|
crc32_finish(self, hash, 4); /* returns void */ |
68
|
17
|
100
|
|
|
|
|
if (ix == 1) { |
69
|
13
|
|
|
|
|
|
rv = base16_encode(hash, 4, out, &outlen, 0); |
70
|
13
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); |
71
|
13
|
|
|
|
|
|
RETVAL = newSVpvn(out, outlen); |
72
|
|
|
|
|
|
|
} |
73
|
4
|
100
|
|
|
|
|
else if (ix == 2) { |
74
|
2
|
|
|
|
|
|
LOAD32H(ui32, hash); |
75
|
2
|
|
|
|
|
|
RETVAL = newSVuv(ui32); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
2
|
|
|
|
|
|
RETVAL = newSVpvn((char *) hash, 4); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
OUTPUT: |
82
|
|
|
|
|
|
|
RETVAL |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
SV * |
85
|
|
|
|
|
|
|
crc32_data(...) |
86
|
|
|
|
|
|
|
ALIAS: |
87
|
|
|
|
|
|
|
crc32_data_hex = 1 |
88
|
|
|
|
|
|
|
crc32_data_int = 2 |
89
|
|
|
|
|
|
|
CODE: |
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
crc32_state st; |
92
|
|
|
|
|
|
|
int rv, j; |
93
|
|
|
|
|
|
|
unsigned char hash[4], *in; |
94
|
|
|
|
|
|
|
char out[9]; |
95
|
11
|
|
|
|
|
|
unsigned long outlen = 9; |
96
|
|
|
|
|
|
|
unsigned int ui32; |
97
|
|
|
|
|
|
|
STRLEN inlen; |
98
|
|
|
|
|
|
|
|
99
|
11
|
|
|
|
|
|
crc32_init(&st); |
100
|
28
|
100
|
|
|
|
|
for(j = 0; j < items; j++) { |
101
|
17
|
50
|
|
|
|
|
in = (unsigned char *)SvPVbyte(ST(j), inlen); |
102
|
17
|
50
|
|
|
|
|
if (inlen > 0) { |
103
|
17
|
|
|
|
|
|
crc32_update(&st, in, (unsigned long)inlen); /* returns void */ |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
11
|
|
|
|
|
|
crc32_finish(&st, hash, 4); /* returns void */ |
107
|
11
|
100
|
|
|
|
|
if (ix == 1) { |
108
|
5
|
|
|
|
|
|
rv = base16_encode(hash, 4, out, &outlen, 0); |
109
|
5
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); |
110
|
5
|
|
|
|
|
|
RETVAL = newSVpvn(out, outlen); |
111
|
|
|
|
|
|
|
} |
112
|
6
|
100
|
|
|
|
|
else if (ix == 2) { |
113
|
4
|
|
|
|
|
|
LOAD32H(ui32, hash); |
114
|
4
|
|
|
|
|
|
RETVAL = newSVuv(ui32); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
else { |
117
|
2
|
|
|
|
|
|
RETVAL = newSVpvn((char *) hash, 4); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
OUTPUT: |
121
|
|
|
|
|
|
|
RETVAL |