inc/CryptX_Checksum_CRC32.xs.inc

filter: Statementstmt 100% 39 / 39 Branchbran 78.5% 22 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 91.0% 61 / 67 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« inc/CryptX_Checksum_Adler32.xs.inc ↑ Summary blib/lib/Crypt/AuthEnc.pm »
1 MODULE = CryptX PACKAGE = Crypt::Checksum::CRC32
2  
3 PROTOTYPES: DISABLE
4  
5 Crypt::Checksum::CRC32
6 new(Class)
7 CODE:
8 {
9 10 Newz(0, RETVAL, 1, crc32_state);
10 10 ▶ if (!RETVAL) croak("FATAL: Newz failed");
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) croak("FATAL: Newz failed"); 0 10 10
11 10 crc32_init(RETVAL); /* returns void */
12 }
13 OUTPUT:
14 RETVAL
15  
16 void
17 DESTROY(Crypt::Checksum::CRC32 self)
18 CODE:
19 11 Safefree(self);
20  
21 void
22 reset(Crypt::Checksum::CRC32 self)
23 PPCODE:
24 {
25 5 crc32_init(self); /* returns void */
26 5 ▶ XPUSHs(ST(0)); /* return self */
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(ST(0)); /* return self */ 0 5 5
27 }
28  
29 Crypt::Checksum::CRC32
30 clone(Crypt::Checksum::CRC32 self)
31 CODE:
32 1 Newz(0, RETVAL, 1, crc32_state);
33 1 ▶ if (!RETVAL) croak("FATAL: Newz failed");
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) croak("FATAL: Newz failed"); 0 1 1
34 1 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 35 ▶ for(i=1; i<items; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i=1; i<items; i++) { 18 17 35
46 18 in = (unsigned char *)SvPVbyte(ST(i), inlen);
47 18 ▶ if (inlen > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (inlen > 0) { 17 1 18
48 17 crc32_update(self, in, (unsigned long)inlen); /* returns void */
49 }
50 }
51 17 ▶ XPUSHs(ST(0)); /* return self */
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(ST(0)); /* return self */ 0 17 17
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 22 unsigned long outlen = 9;
65 unsigned int ui32;
66  
67 22 crc32_finish(self, hash, 4); /* returns void */
68 22 ▶ if (ix == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (ix == 1) { 18 4 22
69 18 rv = base16_encode(hash, 4, out, &outlen, 0);
70 18 ▶ if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); 0 18 18
71 18 RETVAL = newSVpvn(out, outlen);
72 }
73 4 ▶ else if (ix == 2) {
Branch: 1 branch
BranchTrueFalseTotal
else if (ix == 2) { 2 2 4
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 15 unsigned long outlen = 9;
96 unsigned int ui32;
97 STRLEN inlen;
98  
99 15 crc32_init(&st);
100 36 ▶ for(j = 0; j < items; j++) {
Branch: 1 branch
BranchTrueFalseTotal
for(j = 0; j < items; j++) { 21 15 36
101 21 in = (unsigned char *)SvPVbyte(ST(j), inlen);
102 21 ▶ if (inlen > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (inlen > 0) { 20 1 21
103 20 crc32_update(&st, in, (unsigned long)inlen); /* returns void */
104 }
105 }
106 15 crc32_finish(&st, hash, 4); /* returns void */
107 15 ▶ if (ix == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (ix == 1) { 9 6 15
108 9 rv = base16_encode(hash, 4, out, &outlen, 0);
109 9 ▶ if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); 0 9 9
110 9 RETVAL = newSVpvn(out, outlen);
111 }
112 6 ▶ else if (ix == 2) {
Branch: 1 branch
BranchTrueFalseTotal
else if (ix == 2) { 4 2 6
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
« inc/CryptX_Checksum_Adler32.xs.inc ↑ Summary blib/lib/Crypt/AuthEnc.pm »