Explode.xs

filter: Statementstmt 0.0% 0 / 385 Branchbran 0.0% 0 / 438 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 823 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/MIME/Explode.pm ↑ Summary
1 /*
2 * Explode.xs
3 * Last Modification: Sun Jun 26 21:17:45 WEST 2011
4 *
5 * Copyright (c) 2011 Henrique Dias <henrique.ribeiro.dias@gmail.com>.
6 * All rights reserved.
7 * This module is free software; you can redistribute it and/or modify
8 * it under the same terms as Perl itself.
9 *
10 */
11  
12 #ifndef WIN32
13 #include <unistd.h>
14 #endif
15  
16 #ifdef OP_PROTOTYPE
17 #undef OP_PROTOTYPE
18 #endif
19  
20 #define PERL_POLLUTE
21  
22 #include "EXTERN.h"
23 #include "perl.h"
24 #include "XSUB.h"
25  
26 #define BUFFLEN 256
27 #define TMPBUFFLEN 2*256
28 #define ISTEXT 70
29 #define MBXHDRLEN 39
30  
31 #define WSP 0176
32 #define JNK 0177
33 #define PAD 0100
34  
35 #define DEC(Char) (((Char) - ' ') & 077)
36  
37 #ifndef isGRAPH
38 #define isGRAPH(c) (isgraph(c))
39 #endif
40  
41 typedef enum answers {NO = 0, MAYBE = 1, YES = 2} answers;
42  
43 0 bool ismailbox(unsigned char *line) {
44 0 int i = 5, p = 0;
45 0 ▶ if(strlen(line) < MBXHDRLEN ||
Branch: 1 branch
BranchTrueFalseTotal
if(strlen(line) < MBXHDRLEN || 0 0 0
46 0 ▶ line[0] != 'F' || line[1] != 'r' || line[2] != 'o' ||
Branch: 3 branches
BranchTrueFalseTotal
line[0] != 'F' || line[1] != 'r' || line[2] != 'o' || 0 0 0
line[0] != 'F' || line[1] != 'r' || line[2] != 'o' || 0 0 0
line[0] != 'F' || line[1] != 'r' || line[2] != 'o' || 0 0 0
47 0 ▶ line[3] != 'm' || line[4] != 0x20) return FALSE;
Branch: 2 branches
BranchTrueFalseTotal
line[3] != 'm' || line[4] != 0x20) return FALSE; 0 0 0
line[3] != 'm' || line[4] != 0x20) return FALSE; 0 0 0
48 0 ▶ while(line[i] == ' ') i++;
Branch: 1 branch
BranchTrueFalseTotal
while(line[i] == ' ') i++; 0 0 0
49 0 p = i;
50 0 ▶ while(line[i] != '@') {
Branch: 1 branch
BranchTrueFalseTotal
while(line[i] != '@') { 0 0 0
51 0 ▶ if(!isGRAPH(line[i])) return FALSE;
Branch: 1 branch
BranchTrueFalseTotal
if(!isGRAPH(line[i])) return FALSE; 0 0 0
52 0 i++;
53 }
54 0 ▶ if(i-p < 1) return FALSE;
Branch: 1 branch
BranchTrueFalseTotal
if(i-p < 1) return FALSE; 0 0 0
55 0 i += 1;
56 0 p = i;
57 0 ▶ while(line[i] != 0x20) {
Branch: 1 branch
BranchTrueFalseTotal
while(line[i] != 0x20) { 0 0 0
58 0 ▶ if(!(isALNUM(line[i]) || line[i] == '_' || line[i] == '.' ||
Branch: 3 branches
BranchTrueFalseTotal
if(!(isALNUM(line[i]) || line[i] == '_' || line[i] == '.' || 0 0 0
if(!(isALNUM(line[i]) || line[i] == '_' || line[i] == '.' || 0 0 0
if(!(isALNUM(line[i]) || line[i] == '_' || line[i] == '.' || 0 0 0
59 0 ▶ line[i] == '-')) return FALSE;
Branch: 1 branch
BranchTrueFalseTotal
line[i] == '-')) return FALSE; 0 0 0
60 0 i++;
61 }
62 0 ▶ if(i-p < 4) return FALSE;
Branch: 1 branch
BranchTrueFalseTotal
if(i-p < 4) return FALSE; 0 0 0
63 0 i += 1;
64 0 ▶ while(line[i] == 0x20) i++;
Branch: 1 branch
BranchTrueFalseTotal
while(line[i] == 0x20) i++; 0 0 0
65 0 ▶ return((isALPHA(line[i]) && isALPHA(line[i+1]) && isALPHA(line[i+2]) &&
Branch: 2 branches
BranchTrueFalseTotal
return((isALPHA(line[i]) && isALPHA(line[i+1]) && isALPHA(line[i+2]) && 0 0 0
return((isALPHA(line[i]) && isALPHA(line[i+1]) && isALPHA(line[i+2]) && 0 0 0
66 0 ▶ line[i+3] == 0x20 && isALPHA(line[i+4]) && isALPHA(line[i+5]) &&
Branch: 3 branches
BranchTrueFalseTotal
line[i+3] == 0x20 && isALPHA(line[i+4]) && isALPHA(line[i+5]) && 0 0 0
line[i+3] == 0x20 && isALPHA(line[i+4]) && isALPHA(line[i+5]) && 0 0 0
line[i+3] == 0x20 && isALPHA(line[i+4]) && isALPHA(line[i+5]) && 0 0 0
67 0 ▶ isALPHA(line[i+6]) && line[i+7] == 0x20 &&
Branch: 2 branches
BranchTrueFalseTotal
isALPHA(line[i+6]) && line[i+7] == 0x20 && 0 0 0
isALPHA(line[i+6]) && line[i+7] == 0x20 && 0 0 0
68 0 ▶ (line[i+8] == 0x20 || isDIGIT(line[i+8])) && isDIGIT(line[i+9]) &&
Branch: 3 branches
BranchTrueFalseTotal
(line[i+8] == 0x20 || isDIGIT(line[i+8])) && isDIGIT(line[i+9]) && 0 0 0
(line[i+8] == 0x20 || isDIGIT(line[i+8])) && isDIGIT(line[i+9]) && 0 0 0
(line[i+8] == 0x20 || isDIGIT(line[i+8])) && isDIGIT(line[i+9]) && 0 0 0
69 0 ▶ line[i+10] == 0x20 && isDIGIT(line[i+11]) && isDIGIT(line[i+12]) &&
Branch: 3 branches
BranchTrueFalseTotal
line[i+10] == 0x20 && isDIGIT(line[i+11]) && isDIGIT(line[i+12]) && 0 0 0
line[i+10] == 0x20 && isDIGIT(line[i+11]) && isDIGIT(line[i+12]) && 0 0 0
line[i+10] == 0x20 && isDIGIT(line[i+11]) && isDIGIT(line[i+12]) && 0 0 0
70 0 ▶ line[i+13] == ':' && isDIGIT(line[i+14]) && isDIGIT(line[i+15]) &&
Branch: 3 branches
BranchTrueFalseTotal
line[i+13] == ':' && isDIGIT(line[i+14]) && isDIGIT(line[i+15]) && 0 0 0
line[i+13] == ':' && isDIGIT(line[i+14]) && isDIGIT(line[i+15]) && 0 0 0
line[i+13] == ':' && isDIGIT(line[i+14]) && isDIGIT(line[i+15]) && 0 0 0
71 0 ▶ line[i+16] == ':' && isDIGIT(line[i+17]) && isDIGIT(line[i+18]) &&
Branch: 3 branches
BranchTrueFalseTotal
line[i+16] == ':' && isDIGIT(line[i+17]) && isDIGIT(line[i+18]) && 0 0 0
line[i+16] == ':' && isDIGIT(line[i+17]) && isDIGIT(line[i+18]) && 0 0 0
line[i+16] == ':' && isDIGIT(line[i+17]) && isDIGIT(line[i+18]) && 0 0 0
72 0 ▶ line[i+19] == 0x20 && isDIGIT(line[i+20]) && isDIGIT(line[i+21]) &&
Branch: 3 branches
BranchTrueFalseTotal
line[i+19] == 0x20 && isDIGIT(line[i+20]) && isDIGIT(line[i+21]) && 0 0 0
line[i+19] == 0x20 && isDIGIT(line[i+20]) && isDIGIT(line[i+21]) && 0 0 0
line[i+19] == 0x20 && isDIGIT(line[i+20]) && isDIGIT(line[i+21]) && 0 0 0
73 0 ▶ isDIGIT(line[i+22]) && isDIGIT(line[i+23]) && (line[i+24] == 0x0A ||
Branch: 2 branches
BranchTrueFalseTotal
isDIGIT(line[i+22]) && isDIGIT(line[i+23]) && (line[i+24] == 0x0A || 0 0 0
isDIGIT(line[i+22]) && isDIGIT(line[i+23]) && (line[i+24] == 0x0A || 0 0 0
74 0 ▶ (line[i+24] == 0x20 && (line[i+25] == '+' || line[i+25] == '-')&&
Branch: 3 branches
BranchTrueFalseTotal
(line[i+24] == 0x20 && (line[i+25] == '+' || line[i+25] == '-')&& 0 0 0
(line[i+24] == 0x20 && (line[i+25] == '+' || line[i+25] == '-')&& 0 0 0
(line[i+24] == 0x20 && (line[i+25] == '+' || line[i+25] == '-')&& 0 0 0
75 0 ▶ isDIGIT(line[i+26]) && isDIGIT(line[i+27]) &&
Branch: 2 branches
BranchTrueFalseTotal
isDIGIT(line[i+26]) && isDIGIT(line[i+27]) && 0 0 0
isDIGIT(line[i+26]) && isDIGIT(line[i+27]) && 0 0 0
76 0 ▶ isDIGIT(line[i+28]) && isDIGIT(line[i+29]) &&
Branch: 2 branches
BranchTrueFalseTotal
isDIGIT(line[i+28]) && isDIGIT(line[i+29]) && 0 0 0
isDIGIT(line[i+28]) && isDIGIT(line[i+29]) && 0 0 0
77 0 ▶ line[i+30] == 0x0A))) ? TRUE : FALSE);
Branch: 3 branches
BranchTrueFalseTotal
line[i+30] == 0x0A))) ? TRUE : FALSE); 0 0 0
line[i+30] == 0x0A))) ? TRUE : FALSE); 0 0 0
line[i+30] == 0x0A))) ? TRUE : FALSE); 0 0 0
78 }
79  
80 0 bool istext(unsigned char *buff, unsigned long l) {
81 0 unsigned long i = 0, n = 0;
82 0 ▶ for(i = 0; i < l; i++)
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < l; i++) 0 0 0
83 0 ▶ if(isPRINT(buff[i])) n++;
Branch: 1 branch
BranchTrueFalseTotal
if(isPRINT(buff[i])) n++; 0 0 0
84 0 return(((int)(100*((float)n/(float)l)) > ISTEXT) ? TRUE : FALSE);
85 }
86  
87 0 unsigned char *str_to_lower(unsigned char *string) {
88 0 unsigned char *p = string;
89 0 ▶ while(*p = toLOWER(*p)) *p++;
Branch: 2 branches
BranchTrueFalseTotal
while(*p = toLOWER(*p)) *p++; 0 0 0
while(*p = toLOWER(*p)) *p++; 0 0 0
90 0 return string;
91 }
92  
93 0 static char *set_mime_type(unsigned char *buff, unsigned long len, char *base) {
94 0 ▶ if(!len) return base;
Branch: 1 branch
BranchTrueFalseTotal
if(!len) return base; 0 0 0
95 0 ▶ if(istext(buff, len)) {
Branch: 1 branch
BranchTrueFalseTotal
if(istext(buff, len)) { 0 0 0
96 0 ▶ if(len > 4 && buff[0] == '%' &&
Branch: 2 branches
BranchTrueFalseTotal
if(len > 4 && buff[0] == '%' && 0 0 0
if(len > 4 && buff[0] == '%' && 0 0 0
97 0 ▶ !strnNE((char *)buff+1, "PDF-", 4))
Branch: 1 branch
BranchTrueFalseTotal
!strnNE((char *)buff+1, "PDF-", 4)) 0 0 0
98 0 return("application/pdf");
99 0 str_to_lower(buff);
100 0 ▶ if(len > 5) {
Branch: 1 branch
BranchTrueFalseTotal
if(len > 5) { 0 0 0
101 0 ▶ if(instr(buff, "<?xml ")) return("text/xml");
Branch: 1 branch
BranchTrueFalseTotal
if(instr(buff, "<?xml ")) return("text/xml"); 0 0 0
102 0 ▶ if(instr(buff, "<html>")) return("text/html");
Branch: 1 branch
BranchTrueFalseTotal
if(instr(buff, "<html>")) return("text/html"); 0 0 0
103 }
104 0 ▶ return((!strnNE(base, "text/", 5)) ? base : "text/plain");
Branch: 1 branch
BranchTrueFalseTotal
return((!strnNE(base, "text/", 5)) ? base : "text/plain"); 0 0 0
105 } else {
106 0 ▶ if(len > 1 && buff[0] == 0x4d && buff[1] == 0x5a)
Branch: 3 branches
BranchTrueFalseTotal
if(len > 1 && buff[0] == 0x4d && buff[1] == 0x5a) 0 0 0
if(len > 1 && buff[0] == 0x4d && buff[1] == 0x5a) 0 0 0
if(len > 1 && buff[0] == 0x4d && buff[1] == 0x5a) 0 0 0
107 0 return("application/octet-stream");
108 0 ▶ if(len > 2 && buff[0] == 0x47 && buff[1] == 0x49 && buff[2] == 0x46)
Branch: 4 branches
BranchTrueFalseTotal
if(len > 2 && buff[0] == 0x47 && buff[1] == 0x49 && buff[2] == 0x46) 0 0 0
if(len > 2 && buff[0] == 0x47 && buff[1] == 0x49 && buff[2] == 0x46) 0 0 0
if(len > 2 && buff[0] == 0x47 && buff[1] == 0x49 && buff[2] == 0x46) 0 0 0
if(len > 2 && buff[0] == 0x47 && buff[1] == 0x49 && buff[2] == 0x46) 0 0 0
109 0 return("image/gif");
110 0 ▶ if(len > 3) {
Branch: 1 branch
BranchTrueFalseTotal
if(len > 3) { 0 0 0
111 0 ▶ if(buff[0] == 0x89 && buff[1] == 0x50 &&
Branch: 2 branches
BranchTrueFalseTotal
if(buff[0] == 0x89 && buff[1] == 0x50 && 0 0 0
if(buff[0] == 0x89 && buff[1] == 0x50 && 0 0 0
112 0 ▶ buff[2] == 0x4e && buff[3] == 0x47)
Branch: 2 branches
BranchTrueFalseTotal
buff[2] == 0x4e && buff[3] == 0x47) 0 0 0
buff[2] == 0x4e && buff[3] == 0x47) 0 0 0
113 0 return("image/png");
114 0 ▶ if(buff[0] == 0x50 && buff[1] == 0x4b &&
Branch: 2 branches
BranchTrueFalseTotal
if(buff[0] == 0x50 && buff[1] == 0x4b && 0 0 0
if(buff[0] == 0x50 && buff[1] == 0x4b && 0 0 0
115 0 ▶ buff[2] == 0x03 && buff[3] == 0x04)
Branch: 2 branches
BranchTrueFalseTotal
buff[2] == 0x03 && buff[3] == 0x04) 0 0 0
buff[2] == 0x03 && buff[3] == 0x04) 0 0 0
116 0 return("application/x-zip-compressed");
117 }
118 0 ▶ if(len > 4 && buff[0] == '%' &&
Branch: 2 branches
BranchTrueFalseTotal
if(len > 4 && buff[0] == '%' && 0 0 0
if(len > 4 && buff[0] == '%' && 0 0 0
119 0 ▶ strnEQ((char *)buff+1, "PDF-", 4))
Branch: 1 branch
BranchTrueFalseTotal
strnEQ((char *)buff+1, "PDF-", 4)) 0 0 0
120 0 return("application/pdf");
121 0 ▶ if(len > 7 && buff[0] == 0xd0 && buff[1] == 0xcf &&
Branch: 3 branches
BranchTrueFalseTotal
if(len > 7 && buff[0] == 0xd0 && buff[1] == 0xcf && 0 0 0
if(len > 7 && buff[0] == 0xd0 && buff[1] == 0xcf && 0 0 0
if(len > 7 && buff[0] == 0xd0 && buff[1] == 0xcf && 0 0 0
122 0 ▶ buff[2] == 0x11 && buff[3] == 0xe0 &&
Branch: 2 branches
BranchTrueFalseTotal
buff[2] == 0x11 && buff[3] == 0xe0 && 0 0 0
buff[2] == 0x11 && buff[3] == 0xe0 && 0 0 0
123 0 ▶ buff[4] == 0xa1 && buff[5] == 0xb1 &&
Branch: 2 branches
BranchTrueFalseTotal
buff[4] == 0xa1 && buff[5] == 0xb1 && 0 0 0
buff[4] == 0xa1 && buff[5] == 0xb1 && 0 0 0
124 0 ▶ buff[6] == 0x1a && buff[7] == 0xe1)
Branch: 2 branches
BranchTrueFalseTotal
buff[6] == 0x1a && buff[7] == 0xe1) 0 0 0
buff[6] == 0x1a && buff[7] == 0xe1) 0 0 0
125 0 return("application/msword");
126 0 ▶ if(len > 9 && buff[0] == 0xff && buff[1] == 0xd8 &&
Branch: 3 branches
BranchTrueFalseTotal
if(len > 9 && buff[0] == 0xff && buff[1] == 0xd8 && 0 0 0
if(len > 9 && buff[0] == 0xff && buff[1] == 0xd8 && 0 0 0
if(len > 9 && buff[0] == 0xff && buff[1] == 0xd8 && 0 0 0
127 0 ▶ buff[2] == 0xff && buff[3] == 0xe0 &&
Branch: 2 branches
BranchTrueFalseTotal
buff[2] == 0xff && buff[3] == 0xe0 && 0 0 0
buff[2] == 0xff && buff[3] == 0xe0 && 0 0 0
128 0 ▶ strnEQ((char *)&buff[6], "JFIF", 4))
Branch: 1 branch
BranchTrueFalseTotal
strnEQ((char *)&buff[6], "JFIF", 4)) 0 0 0
129 0 return("image/jpeg");
130 0 ▶ if(len > 15 && buff[0] == 0x42 && buff[1] == 0x4d &&
Branch: 3 branches
BranchTrueFalseTotal
if(len > 15 && buff[0] == 0x42 && buff[1] == 0x4d && 0 0 0
if(len > 15 && buff[0] == 0x42 && buff[1] == 0x4d && 0 0 0
if(len > 15 && buff[0] == 0x42 && buff[1] == 0x4d && 0 0 0
131 0 ▶ buff[5] == 0x00 && buff[10] == 0x36 &&
Branch: 2 branches
BranchTrueFalseTotal
buff[5] == 0x00 && buff[10] == 0x36 && 0 0 0
buff[5] == 0x00 && buff[10] == 0x36 && 0 0 0
132 0 ▶ buff[15] == 0x28)
Branch: 1 branch
BranchTrueFalseTotal
buff[15] == 0x28) 0 0 0
133 0 return("image/bmp");
134 0 ▶ return(base ? base : "");
Branch: 1 branch
BranchTrueFalseTotal
return(base ? base : ""); 0 0 0
135 }
136 }
137  
138 0 unsigned char *_rfc822_qprint(unsigned char *src,
139 unsigned long srcl, unsigned long *len) {
140 0 unsigned char *ret = NULL;
141 0 unsigned char *d = NULL;
142 0 unsigned char *t = NULL;
143 0 unsigned char *s = src;
144 unsigned char c, e;
145  
146 0 New(1, ret, (size_t) srcl + 1, unsigned char);
147 0 d = ret;
148 0 t = d;
149 0 *len = 0;
150 0 ▶ while(((unsigned long) (s - src)) < srcl) {
Branch: 1 branch
BranchTrueFalseTotal
while(((unsigned long) (s - src)) < srcl) { 0 0 0
151 0 switch(c = *s++) {
152 0 case '=':
153 0 ▶ if(((unsigned long) (s - src)) < srcl)
Branch: 1 branch
BranchTrueFalseTotal
if(((unsigned long) (s - src)) < srcl) 0 0 0
154 0 switch (c = *s++) {
155 0 case '\0':
156 0 *d++ = '=';
157 0 s--;
158 0 break;
159 0 case '\015':
160 0 ▶ if((((unsigned long) (s - src)) < srcl) && (*s == '\012')) s++;
Branch: 2 branches
BranchTrueFalseTotal
if((((unsigned long) (s - src)) < srcl) && (*s == '\012')) s++; 0 0 0
if((((unsigned long) (s - src)) < srcl) && (*s == '\012')) s++; 0 0 0
161 case '\012':
162 0 t = d;
163 0 break;
164 0 default:
165 0 ▶ if(!(isxdigit(c) && (((unsigned long) (s - src)) < srcl) &&
Branch: 2 branches
BranchTrueFalseTotal
if(!(isxdigit(c) && (((unsigned long) (s - src)) < srcl) && 0 0 0
if(!(isxdigit(c) && (((unsigned long) (s - src)) < srcl) && 0 0 0
166 0 ▶ (e = *s++) && isxdigit(e))) {
Branch: 2 branches
BranchTrueFalseTotal
(e = *s++) && isxdigit(e))) { 0 0 0
(e = *s++) && isxdigit(e))) { 0 0 0
167 // Safefree(ret);
168 // return NULL;
169 0 *d++ = '=';
170 0 s -= 2;
171 0 ▶ if(*s == '=') s++;
Branch: 1 branch
BranchTrueFalseTotal
if(*s == '=') s++; 0 0 0
172 0 t = d;
173 0 break;
174 }
175 0 ▶ if(isDIGIT(c)) c -= '0';
Branch: 1 branch
BranchTrueFalseTotal
if(isDIGIT(c)) c -= '0'; 0 0 0
176 0 ▶ else c -= (isUPPER(c) ? 'A' - 10 : 'a' - 10);
Branch: 1 branch
BranchTrueFalseTotal
else c -= (isUPPER(c) ? 'A' - 10 : 'a' - 10); 0 0 0
177 0 ▶ if(isDIGIT(e)) e -= '0';
Branch: 1 branch
BranchTrueFalseTotal
if(isDIGIT(e)) e -= '0'; 0 0 0
178 0 ▶ else e -= (isUPPER(e) ? 'A' - 10 : 'a' - 10);
Branch: 1 branch
BranchTrueFalseTotal
else e -= (isUPPER(e) ? 'A' - 10 : 'a' - 10); 0 0 0
179 0 *d++ = e + (c << 4);
180 0 t = d;
181 0 break;
182 } else {
183 0 *d++ = '=';
184 0 t = d;
185 }
186 0 break;
187 0 case ' ':
188 0 *d++ = c;
189 0 break;
190 0 case '\015':
191 case '\012':
192 0 d = t;
193 0 default:
194 0 *d++ = c;
195 0 t = d;
196 }
197 }
198 0 *d = '\0';
199 0 *len = d - ret;
200 0 return ret;
201 }
202  
203 /*
204 * From imap-2004a/src/c-client/rfc822.c
205 * Author: Mark Crispin
206 * Copyright 1988-2004 University of Washington.
207 */
208 0 void *_rfc822_base64(unsigned char *src, unsigned long srcl,
209 unsigned long *len) {
210 char c;
211 char *d;
212 int e;
213 void *ret;
214 static unsigned char decode[256] = {
215 WSP,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,WSP,WSP,JNK,WSP,WSP,JNK,JNK,
216 JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
217 WSP,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,076,JNK,JNK,JNK,077,
218 064,065,066,067,070,071,072,073,074,075,JNK,JNK,JNK,PAD,JNK,JNK,
219 JNK,000,001,002,003,004,005,006,007,010,011,012,013,014,015,016,
220 017,020,021,022,023,024,025,026,027,030,031,JNK,JNK,JNK,JNK,JNK,
221 JNK,032,033,034,035,036,037,040,041,042,043,044,045,046,047,050,
222 051,052,053,054,055,056,057,060,061,062,063,JNK,JNK,JNK,JNK,JNK,
223 JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
224 JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
225 JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
226 JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
227 JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
228 JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
229 JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
230 JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK
231 };
232 0 New(0, ret, (size_t) (*len = 4 + ((srcl * 3) / 4)), void);
233 0 d = (char *)ret;
234 0 memset(ret,0,(size_t)*len);
235 0 *len = 0;
236 0 ▶ for(e = 0; srcl--; )
Branch: 1 branch
BranchTrueFalseTotal
for(e = 0; srcl--; ) 0 0 0
237 0 switch(c = decode[*src++]) {
238 0 default:
239 0 switch (e++) {
240 0 case 0:
241 0 *d = c << 2;
242 0 break;
243 0 case 1:
244 0 *d++ |= c >> 4;
245 0 *d = c << 4;
246 0 break;
247 0 case 2:
248 0 *d++ |= c >> 2;
249 0 *d = c << 6;
250 0 break;
251 0 case 3:
252 0 *d++ |= c;
253 0 e = 0;
254 0 break;
255 }
256 0 break;
257 0 case WSP:
258 0 break;
259 0 case PAD:
260 0 switch (e++) {
261 0 case 3:
262 0 ▶ for(; srcl; --srcl)
Branch: 1 branch
BranchTrueFalseTotal
for(; srcl; --srcl) 0 0 0
263 0 ▶ switch (decode[*src++]) {
Branch: 1 branch
BranchTrueFalseTotal
switch (decode[*src++]) { 0 0 0
264 0 case WSP: case JNK: case PAD:
265 0 break;
266 0 default:
267 0 warn("Possible data truncation in _rfc822_base64(): %.80s", (char *)src-1);
268 0 srcl = 1;
269 0 break;
270 }
271 0 break;
272 0 case 2:
273 0 ▶ if(srcl && (*src == '=')) break;
Branch: 2 branches
BranchTrueFalseTotal
if(srcl && (*src == '=')) break; 0 0 0
if(srcl && (*src == '=')) break; 0 0 0
274 default:
275 0 Safefree(ret);
276 0 return NULL;
277 }
278 0 break;
279 0 case JNK:
280 0 Safefree(ret);
281 0 return NULL;
282 }
283 0 *len = d - (char *) ret;
284 0 return ret;
285 }
286  
287  
288 0 void *uu_decode(char *buff, unsigned long srcl, unsigned long *len) {
289 char *p;
290 int n;
291 0 void *ret = NULL;
292 0 char *d = NULL;
293  
294 0 p = buff;
295 0 n = DEC(*p);
296  
297 0 ret = New(2, ret, (size_t) (*len = n + ((3*srcl-6)/4) + 1), void);
298 0 d = (char *)ret;
299 0 memset(ret,0,(size_t)*len);
300 0 *len = 0;
301 0 ▶ if(n <= 0) return("");
Branch: 1 branch
BranchTrueFalseTotal
if(n <= 0) return(""); 0 0 0
302 0 ▶ for(++p; n > 0; p += 4, n -= 3) {
Branch: 1 branch
BranchTrueFalseTotal
for(++p; n > 0; p += 4, n -= 3) { 0 0 0
303 0 ▶ if(n >= 3) {
Branch: 1 branch
BranchTrueFalseTotal
if(n >= 3) { 0 0 0
304 0 *d++ = DEC(p[0]) << 2 | DEC (p[1]) >> 4;
305 0 *d++ = DEC(p[1]) << 4 | DEC (p[2]) >> 2;
306 0 *d++ = DEC(p[2]) << 6 | DEC (p[3]);
307 } else {
308 0 ▶ if(n >= 1)
Branch: 1 branch
BranchTrueFalseTotal
if(n >= 1) 0 0 0
309 0 *d++ = DEC(p[0]) << 2 | DEC (p[1]) >> 4;
310 0 ▶ if(n >= 2)
Branch: 1 branch
BranchTrueFalseTotal
if(n >= 2) 0 0 0
311 0 *d++ = DEC(p[1]) << 4 | DEC (p[2]) >> 2;
312 }
313 }
314 0 *d = '\0';
315 0 *len = d - (char *)ret;
316 0 return(ret);
317 }
318  
319  
320 0 void data_cat(char* tmp, char* data,
321 unsigned long *tmplen, unsigned long len) {
322 0 unsigned int i = 0;
323 0 ▶ for(i = 0; i < len; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < len; i++) { 0 0 0
324 0 ▶ if(*tmplen > TMPBUFFLEN-1) break;
Branch: 1 branch
BranchTrueFalseTotal
if(*tmplen > TMPBUFFLEN-1) break; 0 0 0
325 0 tmp[*tmplen] = data[i];
326 0 (*tmplen)++;
327 }
328 0 tmp[*tmplen] = '\0';
329 0 }
330  
331 MODULE = MIME::Explode PACKAGE = MIME::Explode PREFIX = exp_
332  
333 PROTOTYPES: DISABLE
334  
335 void
336 exp_rfc822_qprint(source)
337 SV *source
338 PREINIT:
339 STRLEN srcl;
340 unsigned long len;
341 unsigned char *s;
342 PPCODE:
343 0 s = (unsigned char*)SvPV(source, srcl);
344 0 ▶ if(s = _rfc822_qprint(s, (unsigned long)srcl, &len)) {
Branch: 1 branch
BranchTrueFalseTotal
if(s = _rfc822_qprint(s, (unsigned long)srcl, &len)) { 0 0 0
345 0 ▶ XPUSHs(sv_2mortal(newSVpv((char*)s, (STRLEN)len)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv((char*)s, (STRLEN)len))); 0 0 0
346 0 Safefree(s);
347 }
348  
349  
350 void
351 exp_rfc822_base64(source)
352 SV *source
353 PREINIT:
354 STRLEN srcl;
355 unsigned long len;
356 unsigned char *s;
357 PPCODE:
358 0 s = (unsigned char*)SvPV(source, srcl);
359 0 ▶ if(s = _rfc822_base64(s, (unsigned long)srcl, &len)) {
Branch: 1 branch
BranchTrueFalseTotal
if(s = _rfc822_base64(s, (unsigned long)srcl, &len)) { 0 0 0
360 0 ▶ XPUSHs(sv_2mortal(newSVpv((char*)s, (STRLEN)len)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv((char*)s, (STRLEN)len))); 0 0 0
361 0 Safefree(s);
362 }
363  
364 void
365 exp_set_content_type(source, ...)
366 SV *source
367 PREINIT:
368 STRLEN srcl;
369 unsigned char *s;
370 0 char *base = NULL;
371 char *mt;
372 PPCODE:
373 0 ▶ if(items == 2) base = SvPV(ST(1), PL_na);
Branch: 1 branch
BranchTrueFalseTotal
if(items == 2) base = SvPV(ST(1), PL_na); 0 0 0
374 0 s = (unsigned char*)SvPV(source, srcl);
375 0 mt = set_mime_type(s, (unsigned long)srcl, base);
376 0 ▶ XPUSHs(sv_2mortal(newSVpv(mt, (STRLEN)strlen(mt))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(mt, (STRLEN)strlen(mt)))); 0 0 0
377  
378  
379 void
380 exp_uu_file(fhs, filename, mode, ...)
381 SV *fhs;
382 char *filename;
383 char *mode;
384 PREINIT:
385 0 PerlIO *fpin = NULL;
386 0 PerlIO *fptmp = NULL;
387 0 PerlIO *fpout = NULL;
388 0 I32 avlen = 0;
389 0 AV *av_fhs = (AV*)SvRV(fhs);
390 HV *hvtypes;
391 0 SV *buff_sv = newSV(BUFFLEN);
392 0 unsigned long len = 0;
393 0 unsigned char *decoded = NULL;
394 0 bool verify = TRUE;
395 0 bool exclude = FALSE;
396 0 bool action = TRUE;
397 0 char mimetype[BUFFLEN] = "";
398 0 AV *av_ret = newAV();
399 char tmp[TMPBUFFLEN];
400 0 unsigned long tmplen = 0;
401 PPCODE:
402 0 ▶ if((avlen = av_len(av_fhs)) != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if((avlen = av_len(av_fhs)) != -1) { 0 0 0
403 0 fpin = IoIFP(sv_2io(*av_fetch(av_fhs, 0, 0)));
404 0 ▶ if(avlen == 1)
Branch: 1 branch
BranchTrueFalseTotal
if(avlen == 1) 0 0 0
405 0 fptmp = IoIFP(sv_2io(*av_fetch(av_fhs, 1, 0)));
406 } else
407 0 croak("Null Array Reference");
408  
409 0 ▶ if(items == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if(items == 4) { 0 0 0
410 0 HV *hv = (HV*)SvRV(ST(3));
411 0 ▶ if(hv_exists(hv, "action", 6)) {
Branch: 1 branch
BranchTrueFalseTotal
if(hv_exists(hv, "action", 6)) { 0 0 0
412 0 SV **value = hv_fetch(hv, "action", 6, 0);
413 0 action = SvIVx(*value) ? TRUE : FALSE;
414 }
415 0 ▶ if(hv_exists(hv, "mimetypes", 9)) {
Branch: 1 branch
BranchTrueFalseTotal
if(hv_exists(hv, "mimetypes", 9)) { 0 0 0
416 0 SV **value = hv_fetch(hv, "mimetypes", 9, 0);
417 0 hvtypes = (HV*)SvRV(*value);
418 }
419 }
420 0 ▶ if((fpout = PerlIO_open(filename, "wb")) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if((fpout = PerlIO_open(filename, "wb")) == NULL) 0 0 0
421 0 croak("Failed to open file \"%s\"", filename);
422  
423 0 ▶ while(sv_gets(buff_sv, fpin, 0)) {
Branch: 1 branch
BranchTrueFalseTotal
while(sv_gets(buff_sv, fpin, 0)) { 0 0 0
424 0 STRLEN l = SvCUR(buff_sv);
425 0 ▶ char *line = SvGROW(buff_sv, l);
Branch: 2 branches
BranchTrueFalseTotal
char *line = SvGROW(buff_sv, l); 0 0 0
char *line = SvGROW(buff_sv, l); 0 0 0
426 0 ▶ if(line[l-1] != 0x0a) break;
Branch: 1 branch
BranchTrueFalseTotal
if(line[l-1] != 0x0a) break; 0 0 0
427 0 ▶ if(fptmp != NULL) PerlIO_write(fptmp, line, l);
Branch: 1 branch
BranchTrueFalseTotal
if(fptmp != NULL) PerlIO_write(fptmp, line, l); 0 0 0
428 0 ▶ if(instr(line, "end\n") || line[0] == 0x0a) break;
Branch: 2 branches
BranchTrueFalseTotal
if(instr(line, "end\n") || line[0] == 0x0a) break; 0 0 0
if(instr(line, "end\n") || line[0] == 0x0a) break; 0 0 0
429 0 ▶ if(!exclude) {
Branch: 1 branch
BranchTrueFalseTotal
if(!exclude) { 0 0 0
430 0 decoded = uu_decode(line, l, &len);
431 0 ▶ if(len) PerlIO_write(fpout, decoded, len);
Branch: 1 branch
BranchTrueFalseTotal
if(len) PerlIO_write(fpout, decoded, len); 0 0 0
432 }
433 0 ▶ if(verify) {
Branch: 1 branch
BranchTrueFalseTotal
if(verify) { 0 0 0
434 0 ▶ if(line[0] == 0x20 || line[0] == 0x0a || line[0] == 0x0d) {
Branch: 3 branches
BranchTrueFalseTotal
if(line[0] == 0x20 || line[0] == 0x0a || line[0] == 0x0d) { 0 0 0
if(line[0] == 0x20 || line[0] == 0x0a || line[0] == 0x0d) { 0 0 0
if(line[0] == 0x20 || line[0] == 0x0a || line[0] == 0x0d) { 0 0 0
435 // nothing to do...
436 } else {
437 0 data_cat(tmp, decoded, &tmplen, len);
438 0 ▶ if(tmplen >= TMPBUFFLEN) {
Branch: 1 branch
BranchTrueFalseTotal
if(tmplen >= TMPBUFFLEN) { 0 0 0
439 0 strcpy(mimetype, set_mime_type(tmp, tmplen, mimetype));
440 0 ▶ exclude = hv_exists(hvtypes, mimetype, strlen(mimetype)) ? (action ? FALSE : TRUE) :
Branch: 2 branches
BranchTrueFalseTotal
exclude = hv_exists(hvtypes, mimetype, strlen(mimetype)) ? (action ? FALSE : TRUE) : 0 0 0
exclude = hv_exists(hvtypes, mimetype, strlen(mimetype)) ? (action ? FALSE : TRUE) : 0 0 0
441 0 hv_iterinit(hvtypes) ? (action ? TRUE : FALSE) : (action ? FALSE : TRUE);
442 0 verify = FALSE;
443 }
444 }
445 }
446 0 ▶ if (decoded) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoded) { 0 0 0
447 0 Safefree(decoded);
448 0 decoded = NULL;
449 0 len = 0;
450 }
451 }
452 0 PerlIO_close(fpout);
453 0 ▶ if(verify) {
Branch: 1 branch
BranchTrueFalseTotal
if(verify) { 0 0 0
454 0 strcpy(mimetype, set_mime_type(tmp, tmplen, mimetype));
455 0 ▶ exclude = hv_exists(hvtypes, mimetype, strlen(mimetype)) ? (action ? FALSE : TRUE) :
Branch: 2 branches
BranchTrueFalseTotal
exclude = hv_exists(hvtypes, mimetype, strlen(mimetype)) ? (action ? FALSE : TRUE) : 0 0 0
exclude = hv_exists(hvtypes, mimetype, strlen(mimetype)) ? (action ? FALSE : TRUE) : 0 0 0
456 0 hv_iterinit(hvtypes) ? (action ? TRUE : FALSE) : (action ? FALSE : TRUE);
457 }
458 0 ▶ if(exclude)
Branch: 1 branch
BranchTrueFalseTotal
if(exclude) 0 0 0
459 0 ▶ if(unlink(filename))
Branch: 1 branch
BranchTrueFalseTotal
if(unlink(filename)) 0 0 0
460 0 croak("Failed to delete file \"%s\"", filename);
461  
462 0 av_push(av_ret, mimetype ? newSVpv(mimetype, 0) : newSVsv(&PL_sv_undef));
463 0 av_push(av_ret, newSViv(exclude ? 1 : 0));
464 0 ▶ XPUSHs(sv_2mortal(newRV_noinc((SV*)av_ret)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newRV_noinc((SV*)av_ret))); 0 0 0
465 0 SvREFCNT_dec(buff_sv);
466  
467  
468 void
469 exp_decode_content(fhs, encoding="base64", filename, boundary="", ...)
470 SV *fhs;
471 char *encoding;
472 char *filename;
473 char *boundary;
474 PREINIT:
475 0 PerlIO *fpin = NULL;
476 0 PerlIO *fptmp = NULL;
477 0 PerlIO *fpout = NULL;
478 0 unsigned char *decoded = NULL;
479 0 unsigned char *rest = NULL;
480 0 SV *buff_sv = newSV(BUFFLEN);
481 0 SV *part = newSVsv(&PL_sv_undef);
482 0 char mt[BUFFLEN] = "";
483 0 bool exclude = FALSE;
484 0 bool verify = TRUE;
485 0 bool checktype = FALSE;
486 0 bool action = TRUE;
487 0 bool last = FALSE;
488 0 I32 avlen = 0;
489 HV *hvtypes;
490 0 AV *av_ret = newAV();
491 0 AV *av_fhs = (AV*)SvRV(fhs);
492 0 unsigned long len = 0;
493 char tmp[TMPBUFFLEN];
494 0 unsigned long tmplen = 0;
495 0 answers findmbox = NO;
496 0 ▶ answers endbase64 = NO;
Branch: 1 branch
BranchTrueFalseTotal
answers endbase64 = NO; 0 0 0
497 char *mimetype;
498 PPCODE:
499 0 ▶ if((avlen = av_len(av_fhs)) != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if((avlen = av_len(av_fhs)) != -1) { 0 0 0
500 0 fpin = IoIFP(sv_2io(*av_fetch(av_fhs, 0, 0)));
501 0 ▶ if(avlen == 1)
Branch: 1 branch
BranchTrueFalseTotal
if(avlen == 1) 0 0 0
502 0 fptmp = IoIFP(sv_2io(*av_fetch(av_fhs, 1, 0)));
503 } else
504 0 croak("Null Array Reference");
505 0 ▶ if(items == 5) {
Branch: 1 branch
BranchTrueFalseTotal
if(items == 5) { 0 0 0
506 0 HV *hv = (HV*)SvRV(ST(4));
507 0 ▶ if(hv_exists(hv, "mimetype", 8)) {
Branch: 1 branch
BranchTrueFalseTotal
if(hv_exists(hv, "mimetype", 8)) { 0 0 0
508 0 SV **value = hv_fetch(hv, "mimetype", 8, 0);
509 0 mimetype = SvPVx(*value, PL_na);
510 }
511 0 ▶ if(hv_exists(hv, "checktype", 9)) {
Branch: 1 branch
BranchTrueFalseTotal
if(hv_exists(hv, "checktype", 9)) { 0 0 0
512 0 SV **value = hv_fetch(hv, "checktype", 9, 0);
513 0 ▶ if(SvIVx(*value)) checktype = TRUE;
Branch: 1 branch
BranchTrueFalseTotal
if(SvIVx(*value)) checktype = TRUE; 0 0 0
514 }
515 0 ▶ if(hv_exists(hv, "action", 6)) {
Branch: 1 branch
BranchTrueFalseTotal
if(hv_exists(hv, "action", 6)) { 0 0 0
516 0 SV **value = hv_fetch(hv, "action", 6, 0);
517 0 action = SvIVx(*value) ? TRUE : FALSE;
518 }
519 0 ▶ if(hv_exists(hv, "mimetypes", 9)) {
Branch: 1 branch
BranchTrueFalseTotal
if(hv_exists(hv, "mimetypes", 9)) { 0 0 0
520 0 SV **value = hv_fetch(hv, "mimetypes", 9, 0);
521 0 hvtypes = (HV*)SvRV(*value);
522 }
523 0 ▶ if(hv_exists(hv, "mailbox", 7)) {
Branch: 1 branch
BranchTrueFalseTotal
if(hv_exists(hv, "mailbox", 7)) { 0 0 0
524 0 SV **value = hv_fetch(hv, "mailbox", 7, 0);
525 0 ▶ if(SvIVx(*value)) findmbox = MAYBE;
Branch: 1 branch
BranchTrueFalseTotal
if(SvIVx(*value)) findmbox = MAYBE; 0 0 0
526 }
527 }
528 0 ▶ if((fpout = PerlIO_open(filename, "wb")) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if((fpout = PerlIO_open(filename, "wb")) == NULL) 0 0 0
529 0 croak("Failed to open file \"%s\"", filename);
530 0 ▶ while(!last && sv_gets(buff_sv, fpin, 0)) {
Branch: 2 branches
BranchTrueFalseTotal
while(!last && sv_gets(buff_sv, fpin, 0)) { 0 0 0
while(!last && sv_gets(buff_sv, fpin, 0)) { 0 0 0
531 0 STRLEN l = SvCUR(buff_sv);
532 0 ▶ char *line = SvGROW(buff_sv, l);
Branch: 2 branches
BranchTrueFalseTotal
char *line = SvGROW(buff_sv, l); 0 0 0
char *line = SvGROW(buff_sv, l); 0 0 0
533 0 ▶ if(fptmp != NULL) PerlIO_write(fptmp, line, l);
Branch: 1 branch
BranchTrueFalseTotal
if(fptmp != NULL) PerlIO_write(fptmp, line, l); 0 0 0
534 0 ▶ if(findmbox == YES) {
Branch: 1 branch
BranchTrueFalseTotal
if(findmbox == YES) { 0 0 0
535 0 ▶ if(ismailbox(line)) {
Branch: 1 branch
BranchTrueFalseTotal
if(ismailbox(line)) { 0 0 0
536 0 sv_setsv(part, buff_sv);
537 0 break;
538 }
539 0 findmbox = MAYBE;
540 }
541 0 ▶ if(line[0] == 0x0a && findmbox == MAYBE) {
Branch: 2 branches
BranchTrueFalseTotal
if(line[0] == 0x0a && findmbox == MAYBE) { 0 0 0
if(line[0] == 0x0a && findmbox == MAYBE) { 0 0 0
542 0 findmbox = YES;
543 0 ▶ if(encoding[0] == 'b') continue;
Branch: 1 branch
BranchTrueFalseTotal
if(encoding[0] == 'b') continue; 0 0 0
544 }
545 0 ▶ if(encoding[0] == 'b') {
Branch: 1 branch
BranchTrueFalseTotal
if(encoding[0] == 'b') { 0 0 0
546 0 ▶ if(boundary[0] != '\0' && line[l-1] != 0x0a) break;
Branch: 2 branches
BranchTrueFalseTotal
if(boundary[0] != '\0' && line[l-1] != 0x0a) break; 0 0 0
if(boundary[0] != '\0' && line[l-1] != 0x0a) break; 0 0 0
547 0 ▶ if(line[l-2] == '=' && line[l-1] == 0x0a) endbase64 = MAYBE;
Branch: 2 branches
BranchTrueFalseTotal
if(line[l-2] == '=' && line[l-1] == 0x0a) endbase64 = MAYBE; 0 0 0
if(line[l-2] == '=' && line[l-1] == 0x0a) endbase64 = MAYBE; 0 0 0
548 }
549 0 ▶ if(boundary[0] != '\0' && (rest = instr(line, boundary))) {
Branch: 2 branches
BranchTrueFalseTotal
if(boundary[0] != '\0' && (rest = instr(line, boundary))) { 0 0 0
if(boundary[0] != '\0' && (rest = instr(line, boundary))) { 0 0 0
550 0 sv_setpvn(part, rest, strlen(rest));
551 0 l -= SvCUR(part);
552 0 ▶ if(l == 0) break;
Branch: 1 branch
BranchTrueFalseTotal
if(l == 0) break; 0 0 0
553 0 line[l] = '\0';
554 0 last = TRUE;
555 0 ▶ } else if(endbase64 == YES && line[0] != 0x0a) {
Branch: 2 branches
BranchTrueFalseTotal
} else if(endbase64 == YES && line[0] != 0x0a) { 0 0 0
} else if(endbase64 == YES && line[0] != 0x0a) { 0 0 0
556 0 sv_setpvn(part, line, l);
557 0 break;
558 }
559 0 ▶ if(!exclude) {
Branch: 1 branch
BranchTrueFalseTotal
if(!exclude) { 0 0 0
560 0 decoded = (encoding[0] == 'q') ?
561 0 ▶ _rfc822_qprint(line, l, &len) : _rfc822_base64(line, l, &len);
Branch: 1 branch
BranchTrueFalseTotal
_rfc822_qprint(line, l, &len) : _rfc822_base64(line, l, &len); 0 0 0
562 0 ▶ if(len) PerlIO_write(fpout, decoded, len);
Branch: 1 branch
BranchTrueFalseTotal
if(len) PerlIO_write(fpout, decoded, len); 0 0 0
563 }
564 0 ▶ if(!last) {
Branch: 1 branch
BranchTrueFalseTotal
if(!last) { 0 0 0
565 0 ▶ if(endbase64 == MAYBE) endbase64 = YES;
Branch: 1 branch
BranchTrueFalseTotal
if(endbase64 == MAYBE) endbase64 = YES; 0 0 0
566 0 ▶ if(verify) {
Branch: 1 branch
BranchTrueFalseTotal
if(verify) { 0 0 0
567 0 ▶ if((encoding[0] == 'b' && line[0] == 0x20) || line[0] == 0x0a || line[0] == 0x0d) {
Branch: 4 branches
BranchTrueFalseTotal
if((encoding[0] == 'b' && line[0] == 0x20) || line[0] == 0x0a || line[0] == 0x0d) { 0 0 0
if((encoding[0] == 'b' && line[0] == 0x20) || line[0] == 0x0a || line[0] == 0x0d) { 0 0 0
if((encoding[0] == 'b' && line[0] == 0x20) || line[0] == 0x0a || line[0] == 0x0d) { 0 0 0
if((encoding[0] == 'b' && line[0] == 0x20) || line[0] == 0x0a || line[0] == 0x0d) { 0 0 0
568 // nothing to do...
569 } else {
570 0 data_cat(tmp, decoded, &tmplen, len);
571 0 ▶ if(tmplen >= TMPBUFFLEN) {
Branch: 1 branch
BranchTrueFalseTotal
if(tmplen >= TMPBUFFLEN) { 0 0 0
572 0 ▶ strcpy(mt, (checktype) ? set_mime_type(tmp, tmplen, mimetype) : mimetype);
Branch: 1 branch
BranchTrueFalseTotal
strcpy(mt, (checktype) ? set_mime_type(tmp, tmplen, mimetype) : mimetype); 0 0 0
573 0 ▶ exclude = hv_exists(hvtypes, mt, strlen(mt)) ? (action ? FALSE : TRUE) :
Branch: 2 branches
BranchTrueFalseTotal
exclude = hv_exists(hvtypes, mt, strlen(mt)) ? (action ? FALSE : TRUE) : 0 0 0
exclude = hv_exists(hvtypes, mt, strlen(mt)) ? (action ? FALSE : TRUE) : 0 0 0
574 0 hv_iterinit(hvtypes) ? (action ? TRUE : FALSE) : (action ? FALSE : TRUE);
575 0 verify = FALSE;
576 }
577 }
578 }
579 }
580 0 ▶ if(decoded) {
Branch: 1 branch
BranchTrueFalseTotal
if(decoded) { 0 0 0
581 0 Safefree(decoded);
582 0 decoded = NULL;
583 0 len = 0;
584 }
585 }
586 0 PerlIO_close(fpout);
587 0 ▶ if(verify) {
Branch: 1 branch
BranchTrueFalseTotal
if(verify) { 0 0 0
588 0 ▶ strcpy(mt, (checktype) ? set_mime_type(tmp, tmplen, mimetype) : mimetype);
Branch: 1 branch
BranchTrueFalseTotal
strcpy(mt, (checktype) ? set_mime_type(tmp, tmplen, mimetype) : mimetype); 0 0 0
589 0 ▶ exclude = hv_exists(hvtypes, mt, strlen(mt)) ? (action ? FALSE : TRUE) :
Branch: 2 branches
BranchTrueFalseTotal
exclude = hv_exists(hvtypes, mt, strlen(mt)) ? (action ? FALSE : TRUE) : 0 0 0
exclude = hv_exists(hvtypes, mt, strlen(mt)) ? (action ? FALSE : TRUE) : 0 0 0
590 0 hv_iterinit(hvtypes) ? (action ? TRUE : FALSE) : (action ? FALSE : TRUE);
591 }
592 0 ▶ if(exclude)
Branch: 1 branch
BranchTrueFalseTotal
if(exclude) 0 0 0
593 0 ▶ if(unlink(filename))
Branch: 1 branch
BranchTrueFalseTotal
if(unlink(filename)) 0 0 0
594 0 croak("Failed to delete file \"%s\"", filename);
595 0 av_push(av_ret, part);
596 0 av_push(av_ret, mt ? newSVpv(mt, 0) : newSVsv(&PL_sv_undef));
597 0 av_push(av_ret, newSViv(exclude ? 1 : 0));
598 0 ▶ XPUSHs(sv_2mortal(newRV_noinc((SV*)av_ret)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newRV_noinc((SV*)av_ret))); 0 0 0
599 0 SvREFCNT_dec(buff_sv);
« blib/lib/MIME/Explode.pm ↑ Summary