Mercurial > libpst
comparison src/readpst.c @ 36:6fe121a971c9 stable-0-5-7
valgrind fixes
author | carl |
---|---|
date | Thu, 09 Aug 2007 15:46:34 -0700 |
parents | 07177825c91b |
children | ddfb25318812 |
comparison
equal
deleted
inserted
replaced
35:b2f247463b83 | 36:6fe121a971c9 |
---|---|
1003 } | 1003 } |
1004 } | 1004 } |
1005 if (current_attach->data) { | 1005 if (current_attach->data) { |
1006 fwrite(enc, 1, strlen(enc), f_output); | 1006 fwrite(enc, 1, strlen(enc), f_output); |
1007 DEBUG_EMAIL(("Attachment Size after encoding is %i\n", strlen(enc))); | 1007 DEBUG_EMAIL(("Attachment Size after encoding is %i\n", strlen(enc))); |
1008 free(enc); // caught by valgrind | |
1008 } else { | 1009 } else { |
1009 pst_attach_to_file_base64(pst, current_attach, f_output); | 1010 pst_attach_to_file_base64(pst, current_attach, f_output); |
1010 } | 1011 } |
1011 fprintf(f_output, "\n\n"); | 1012 fprintf(f_output, "\n\n"); |
1012 DEBUG_RET(); | 1013 DEBUG_RET(); |
1200 if (base64_body) | 1201 if (base64_body) |
1201 fprintf(f_output, "Content-Transfer-Encoding: base64\n"); | 1202 fprintf(f_output, "Content-Transfer-Encoding: base64\n"); |
1202 fprintf(f_output, "\n"); | 1203 fprintf(f_output, "\n"); |
1203 } | 1204 } |
1204 removeCR(item->email->body); | 1205 removeCR(item->email->body); |
1205 if (base64_body) | 1206 if (base64_body) { |
1206 write_email_body(f_output, base64_encode(item->email->body, strlen(item->email->body))); | 1207 char *enc = base64_encode(item->email->body, strlen(item->email->body)); |
1207 else | 1208 if (enc) { |
1209 write_email_body(f_output, enc); | |
1210 free(enc); | |
1211 } | |
1212 } | |
1213 else { | |
1208 write_email_body(f_output, item->email->body); | 1214 write_email_body(f_output, item->email->body); |
1215 } | |
1209 } | 1216 } |
1210 | 1217 |
1211 if (item->email->htmlbody) { | 1218 if (item->email->htmlbody) { |
1212 if (boundary) { | 1219 if (boundary) { |
1213 fprintf(f_output, "\n--%s\n", boundary); | 1220 fprintf(f_output, "\n--%s\n", boundary); |
1214 fprintf(f_output, "Content-type: text/html\n"); | 1221 fprintf(f_output, "Content-type: text/html\n"); |
1215 if (base64_body) | 1222 if (base64_body) fprintf(f_output, "Content-Transfer-Encoding: base64\n"); |
1216 fprintf(f_output, "Content-Transfer-Encoding: base64\n"); | |
1217 fprintf(f_output, "\n"); | 1223 fprintf(f_output, "\n"); |
1218 } | 1224 } |
1219 removeCR(item->email->htmlbody); | 1225 removeCR(item->email->htmlbody); |
1220 if (base64_body) | 1226 if (base64_body) { |
1221 write_email_body(f_output, base64_encode(item->email->htmlbody, strlen(item->email->htmlbody))); | 1227 char *enc = base64_encode(item->email->htmlbody, strlen(item->email->htmlbody)); |
1222 else | 1228 if (enc) { |
1229 write_email_body(f_output, enc); | |
1230 free(enc); | |
1231 } | |
1232 } | |
1233 else { | |
1223 write_email_body(f_output, item->email->htmlbody); | 1234 write_email_body(f_output, item->email->htmlbody); |
1235 } | |
1224 } | 1236 } |
1225 | 1237 |
1226 if (item->email->rtf_compressed && save_rtf) { | 1238 if (item->email->rtf_compressed && save_rtf) { |
1227 DEBUG_EMAIL(("Adding RTF body as attachment\n")); | 1239 DEBUG_EMAIL(("Adding RTF body as attachment\n")); |
1228 current_attach = (pst_item_attach*)xmalloc(sizeof(pst_item_attach)); | 1240 current_attach = (pst_item_attach*)xmalloc(sizeof(pst_item_attach)); |
1229 memset(current_attach, 0, sizeof(pst_item_attach)); | 1241 memset(current_attach, 0, sizeof(pst_item_attach)); |
1230 current_attach->next = item->attach; | 1242 current_attach->next = item->attach; |
1231 item->attach = current_attach; | 1243 item->attach = current_attach; |
1232 current_attach->data = lzfu_decompress(item->email->rtf_compressed); | 1244 current_attach->data = lzfu_decompress(item->email->rtf_compressed, ¤t_attach->size); |
1233 current_attach->filename2 = xmalloc(strlen(RTF_ATTACH_NAME)+2); | 1245 current_attach->filename2 = xmalloc(strlen(RTF_ATTACH_NAME)+2); |
1234 strcpy(current_attach->filename2, RTF_ATTACH_NAME); | 1246 strcpy(current_attach->filename2, RTF_ATTACH_NAME); |
1235 current_attach->mimetype = xmalloc(strlen(RTF_ATTACH_TYPE)+2); | 1247 current_attach->mimetype = xmalloc(strlen(RTF_ATTACH_TYPE)+2); |
1236 strcpy(current_attach->mimetype, RTF_ATTACH_TYPE); | 1248 strcpy(current_attach->mimetype, RTF_ATTACH_TYPE); |
1237 memcpy(&(current_attach->size), item->email->rtf_compressed+sizeof(int32_t), sizeof(int32_t)); | 1249 memcpy(&(current_attach->size), item->email->rtf_compressed+sizeof(int32_t), sizeof(int32_t)); |
1263 } | 1275 } |
1264 write_email_body(f_output, "The body of this email is encrypted. This isn't supported yet, but the body is now an attachment\n"); | 1276 write_email_body(f_output, "The body of this email is encrypted. This isn't supported yet, but the body is now an attachment\n"); |
1265 } | 1277 } |
1266 | 1278 |
1267 // attachments | 1279 // attachments |
1268 base64_body = 0; | |
1269 attach_num = 0; | 1280 attach_num = 0; |
1270 for (current_attach = item->attach; | 1281 for (current_attach = item->attach; |
1271 current_attach; | 1282 current_attach; |
1272 current_attach = current_attach->next) { | 1283 current_attach = current_attach->next) { |
1273 DEBUG_EMAIL(("Attempting Attachment encoding\n")); | 1284 DEBUG_EMAIL(("Attempting Attachment encoding\n")); |
1321 (!contact->home_postal_code) ? "" : rfc2426_escape(contact->home_postal_code), | 1332 (!contact->home_postal_code) ? "" : rfc2426_escape(contact->home_postal_code), |
1322 (!contact->home_country) ? "" : rfc2426_escape(contact->home_country)); | 1333 (!contact->home_country) ? "" : rfc2426_escape(contact->home_country)); |
1323 fprintf(f_output, "LABEL;TYPE=home:%s\n", rfc2426_escape(contact->home_address)); | 1334 fprintf(f_output, "LABEL;TYPE=home:%s\n", rfc2426_escape(contact->home_address)); |
1324 } | 1335 } |
1325 if (contact->business_address) { | 1336 if (contact->business_address) { |
1326 fprintf(f_output, "ADR;TYPE=work:%s;%s;%s;%s;%s;%s;%s\n", | 1337 // these should be equivalent, but valgrind complains about the single large fprintf |
1327 (!contact->business_po_box) ? "" : rfc2426_escape(contact->business_po_box), | 1338 // |
1328 "", // extended Address | 1339 char *ab = (!contact->business_po_box ) ? "" : rfc2426_escape(contact->business_po_box ); |
1329 (!contact->business_street) ? "" : rfc2426_escape(contact->business_street), | 1340 char *ac = (!contact->business_street ) ? "" : rfc2426_escape(contact->business_street ); |
1330 (!contact->business_city) ? "" : rfc2426_escape(contact->business_city), | 1341 char *ad = (!contact->business_city ) ? "" : rfc2426_escape(contact->business_city ); |
1331 (!contact->business_state) ? "" : rfc2426_escape(contact->business_state), | 1342 char *ae = (!contact->business_state ) ? "" : rfc2426_escape(contact->business_state ); |
1332 (!contact->business_postal_code) ? "" : rfc2426_escape(contact->business_postal_code), | 1343 char *af = (!contact->business_postal_code) ? "" : rfc2426_escape(contact->business_postal_code); |
1333 (!contact->business_country) ? "" : rfc2426_escape(contact->business_country)); | 1344 char *ag = (!contact->business_country ) ? "" : rfc2426_escape(contact->business_country ); |
1345 fprintf(f_output, "ADR;TYPE=work:%s;%s;%s;%s;%s;%s;%s\n", ab, "", ac, ad, ae, af, ag); | |
1346 //fprintf(f_output, "ADR;TYPE=work:%s;%s;%s;%s;%s;%s;%s\n", | |
1347 // (!contact->business_po_box) ? "" : rfc2426_escape(contact->business_po_box), | |
1348 // "", // extended Address | |
1349 // (!contact->business_street) ? "" : rfc2426_escape(contact->business_street), | |
1350 // (!contact->business_city) ? "" : rfc2426_escape(contact->business_city), | |
1351 // (!contact->business_state) ? "" : rfc2426_escape(contact->business_state), | |
1352 // (!contact->business_postal_code) ? "" : rfc2426_escape(contact->business_postal_code), | |
1353 // (!contact->business_country) ? "" : rfc2426_escape(contact->business_country)); | |
1334 fprintf(f_output, "LABEL;TYPE=work:%s\n", rfc2426_escape(contact->business_address)); | 1354 fprintf(f_output, "LABEL;TYPE=work:%s\n", rfc2426_escape(contact->business_address)); |
1335 } | 1355 } |
1336 if (contact->other_address) { | 1356 if (contact->other_address) { |
1337 fprintf(f_output, "ADR;TYPE=postal:%s;%s;%s;%s;%s;%s;%s\n", | 1357 fprintf(f_output, "ADR;TYPE=postal:%s;%s;%s;%s;%s;%s;%s\n", |
1338 (!contact->other_po_box) ? "" : rfc2426_escape(contact->business_po_box), | 1358 (!contact->other_po_box) ? "" : rfc2426_escape(contact->other_po_box), |
1339 "", // extended Address | 1359 "", // extended Address |
1340 (!contact->other_street) ? "" : rfc2426_escape(contact->other_street), | 1360 (!contact->other_street) ? "" : rfc2426_escape(contact->other_street), |
1341 (!contact->other_city) ? "" : rfc2426_escape(contact->other_city), | 1361 (!contact->other_city) ? "" : rfc2426_escape(contact->other_city), |
1342 (!contact->other_state) ? "" : rfc2426_escape(contact->other_state), | 1362 (!contact->other_state) ? "" : rfc2426_escape(contact->other_state), |
1343 (!contact->other_postal_code) ? "" : rfc2426_escape(contact->other_postal_code), | 1363 (!contact->other_postal_code) ? "" : rfc2426_escape(contact->other_postal_code), |