Mercurial > libpst
comparison src/readpst.c @ 37:ddfb25318812 stable-0-5-8
more valgrind fixes
author | carl |
---|---|
date | Fri, 10 Aug 2007 08:06:13 -0700 |
parents | 6fe121a971c9 |
children | f5c024aa1dc5 |
comparison
equal
deleted
inserted
replaced
36:6fe121a971c9 | 37:ddfb25318812 |
---|---|
289 } | 289 } |
290 DEBUG_MAIN(("main: Desc Email ID %#x [d_ptr->id = %#x]\n", d_ptr->desc->id, d_ptr->id)); | 290 DEBUG_MAIN(("main: Desc Email ID %#x [d_ptr->id = %#x]\n", d_ptr->desc->id, d_ptr->id)); |
291 | 291 |
292 item = _pst_parse_item(&pstfile, d_ptr); | 292 item = _pst_parse_item(&pstfile, d_ptr); |
293 DEBUG_MAIN(("main: About to process item\n")); | 293 DEBUG_MAIN(("main: About to process item\n")); |
294 if (item && item->email && item->email->subject && | 294 if (item && item->email && item->email->subject && item->email->subject->subj) { |
295 item->email->subject->subj) { | 295 DEBUG_EMAIL(("item->email->subject = %p\n", item->email->subject)); |
296 // DEBUG_EMAIL(("item->email->subject = %p\n", item->email->subject)); | 296 DEBUG_EMAIL(("item->email->subject->subj = %p\n", item->email->subject->subj)); |
297 // DEBUG_EMAIL(("item->email->subject->subj = %p\n", item->email->subject->subj)); | |
298 } | 297 } |
299 if (item) { | 298 if (item) { |
300 if (item->message_store) { | 299 if (item->message_store) { |
301 // there should only be one message_store, and we have already done it | 300 // there should only be one message_store, and we have already done it |
302 DIE(("main: A second message_store has been found. Sorry, this must be an error.\n")); | 301 DIE(("main: A second message_store has been found. Sorry, this must be an error.\n")); |
339 free(f); | 338 free(f); |
340 | 339 |
341 f = head; | 340 f = head; |
342 } | 341 } |
343 _pst_freeItem(item); | 342 _pst_freeItem(item); |
344 item = NULL; // just for the odd situations! | 343 item = NULL; |
345 goto check_parent; | 344 goto check_parent; |
346 } else if (item->contact) { | 345 } else if (item->contact) { |
347 // deal with a contact | 346 // deal with a contact |
348 // write them to the file, one per line in this format | 347 // write them to the file, one per line in this format |
349 // Desc Name <email@address>\n | 348 // Desc Name <email@address>\n |
430 check_parent: | 429 check_parent: |
431 // _pst_freeItem(item); | 430 // _pst_freeItem(item); |
432 while (!skip_child && !d_ptr->next && d_ptr->parent) { | 431 while (!skip_child && !d_ptr->next && d_ptr->parent) { |
433 DEBUG_MAIN(("main: Going to Parent\n")); | 432 DEBUG_MAIN(("main: Going to Parent\n")); |
434 head = f->next; | 433 head = f->next; |
435 if (f->output) | 434 if (f->output) fclose(f->output); |
436 fclose(f->output); | |
437 DEBUG_MAIN(("main: Email Count for folder %s is %i\n", f->dname, f->email_count)); | 435 DEBUG_MAIN(("main: Email Count for folder %s is %i\n", f->dname, f->email_count)); |
438 if (output_mode != OUTPUT_QUIET) | 436 if (output_mode != OUTPUT_QUIET) |
439 printf("\t\"%s\" - %i items done, skipped %i, should have been %i\n", | 437 printf("\t\"%s\" - %i items done, skipped %i, should have been %i\n", |
440 f->dname, f->email_count, f->skip_count, f->stored_count); | 438 f->dname, f->email_count, f->skip_count, f->stored_count); |
441 if (mode == MODE_KMAIL) | 439 if (mode == MODE_KMAIL) |
475 DEBUG_MAIN(("main: Finished.\n")); | 473 DEBUG_MAIN(("main: Finished.\n")); |
476 | 474 |
477 pst_close(&pstfile); | 475 pst_close(&pstfile); |
478 // fclose(pstfile.fp); | 476 // fclose(pstfile.fp); |
479 while (f) { | 477 while (f) { |
480 if (f->output) | 478 if (f->output) fclose(f->output); |
481 fclose(f->output); | |
482 free(f->name); | 479 free(f->name); |
483 free(f->dname); | 480 free(f->dname); |
484 | 481 |
485 if (mode == MODE_KMAIL) | 482 if (mode == MODE_KMAIL) |
486 close_kmail_dir(); | 483 close_kmail_dir(); |
1234 write_email_body(f_output, item->email->htmlbody); | 1231 write_email_body(f_output, item->email->htmlbody); |
1235 } | 1232 } |
1236 } | 1233 } |
1237 | 1234 |
1238 if (item->email->rtf_compressed && save_rtf) { | 1235 if (item->email->rtf_compressed && save_rtf) { |
1236 //int32_t tester; | |
1239 DEBUG_EMAIL(("Adding RTF body as attachment\n")); | 1237 DEBUG_EMAIL(("Adding RTF body as attachment\n")); |
1240 current_attach = (pst_item_attach*)xmalloc(sizeof(pst_item_attach)); | 1238 current_attach = (pst_item_attach*)xmalloc(sizeof(pst_item_attach)); |
1241 memset(current_attach, 0, sizeof(pst_item_attach)); | 1239 memset(current_attach, 0, sizeof(pst_item_attach)); |
1242 current_attach->next = item->attach; | 1240 current_attach->next = item->attach; |
1243 item->attach = current_attach; | 1241 item->attach = current_attach; |
1244 current_attach->data = lzfu_decompress(item->email->rtf_compressed, ¤t_attach->size); | 1242 current_attach->data = lzfu_decompress(item->email->rtf_compressed, ¤t_attach->size); |
1245 current_attach->filename2 = xmalloc(strlen(RTF_ATTACH_NAME)+2); | 1243 current_attach->filename2 = xmalloc(strlen(RTF_ATTACH_NAME)+2); |
1246 strcpy(current_attach->filename2, RTF_ATTACH_NAME); | 1244 strcpy(current_attach->filename2, RTF_ATTACH_NAME); |
1247 current_attach->mimetype = xmalloc(strlen(RTF_ATTACH_TYPE)+2); | 1245 current_attach->mimetype = xmalloc(strlen(RTF_ATTACH_TYPE)+2); |
1248 strcpy(current_attach->mimetype, RTF_ATTACH_TYPE); | 1246 strcpy(current_attach->mimetype, RTF_ATTACH_TYPE); |
1249 memcpy(&(current_attach->size), item->email->rtf_compressed+sizeof(int32_t), sizeof(int32_t)); | 1247 //memcpy(&tester, item->email->rtf_compressed+sizeof(int32_t), sizeof(int32_t)); |
1250 LE32_CPU(current_attach->size); | 1248 //LE32_CPU(tester); |
1249 //printf("lz produced %d bytes, rtf claims %d bytes\n", current_attach->size, tester); | |
1251 } | 1250 } |
1252 | 1251 |
1253 if (item->email->encrypted_body || item->email->encrypted_htmlbody) { | 1252 if (item->email->encrypted_body || item->email->encrypted_htmlbody) { |
1254 // if either the body or htmlbody is encrypted, add them as attachments | 1253 // if either the body or htmlbody is encrypted, add them as attachments |
1255 if (item->email->encrypted_body) { | 1254 if (item->email->encrypted_body) { |
1305 DEBUG_ENT("write_vcard"); | 1304 DEBUG_ENT("write_vcard"); |
1306 // the specification I am following is (hopefully) RFC2426 vCard Mime Directory Profile | 1305 // the specification I am following is (hopefully) RFC2426 vCard Mime Directory Profile |
1307 fprintf(f_output, "BEGIN:VCARD\n"); | 1306 fprintf(f_output, "BEGIN:VCARD\n"); |
1308 fprintf(f_output, "FN:%s\n", rfc2426_escape(contact->fullname)); | 1307 fprintf(f_output, "FN:%s\n", rfc2426_escape(contact->fullname)); |
1309 fprintf(f_output, "N:%s;%s;%s;%s;%s\n", | 1308 fprintf(f_output, "N:%s;%s;%s;%s;%s\n", |
1310 (!contact->surname) ? "" : rfc2426_escape(contact->surname), | 1309 (!contact->surname) ? "" : rfc2426_escape(contact->surname), |
1311 (!contact->first_name) ? "" : rfc2426_escape(contact->first_name), | 1310 (!contact->first_name) ? "" : rfc2426_escape(contact->first_name), |
1312 (!contact->middle_name) ? "" : rfc2426_escape(contact->middle_name), | 1311 (!contact->middle_name) ? "" : rfc2426_escape(contact->middle_name), |
1313 (!contact->display_name_prefix) ? "" : rfc2426_escape(contact->display_name_prefix), | 1312 (!contact->display_name_prefix) ? "" : rfc2426_escape(contact->display_name_prefix), |
1314 (!contact->suffix) ? "" : rfc2426_escape(contact->suffix)); | 1313 (!contact->suffix) ? "" : rfc2426_escape(contact->suffix)); |
1315 if (contact->nickname) | 1314 if (contact->nickname) |
1334 fprintf(f_output, "LABEL;TYPE=home:%s\n", rfc2426_escape(contact->home_address)); | 1333 fprintf(f_output, "LABEL;TYPE=home:%s\n", rfc2426_escape(contact->home_address)); |
1335 } | 1334 } |
1336 if (contact->business_address) { | 1335 if (contact->business_address) { |
1337 // these should be equivalent, but valgrind complains about the single large fprintf | 1336 // these should be equivalent, but valgrind complains about the single large fprintf |
1338 // | 1337 // |
1339 char *ab = (!contact->business_po_box ) ? "" : rfc2426_escape(contact->business_po_box ); | 1338 char *ab = (!contact->business_po_box ) ? "" : rfc2426_escape(contact->business_po_box ); |
1340 char *ac = (!contact->business_street ) ? "" : rfc2426_escape(contact->business_street ); | 1339 char *ac = (!contact->business_street ) ? "" : rfc2426_escape(contact->business_street ); |
1341 char *ad = (!contact->business_city ) ? "" : rfc2426_escape(contact->business_city ); | 1340 char *ad = (!contact->business_city ) ? "" : rfc2426_escape(contact->business_city ); |
1342 char *ae = (!contact->business_state ) ? "" : rfc2426_escape(contact->business_state ); | 1341 char *ae = (!contact->business_state ) ? "" : rfc2426_escape(contact->business_state ); |
1343 char *af = (!contact->business_postal_code) ? "" : rfc2426_escape(contact->business_postal_code); | 1342 char *af = (!contact->business_postal_code) ? "" : rfc2426_escape(contact->business_postal_code); |
1344 char *ag = (!contact->business_country ) ? "" : rfc2426_escape(contact->business_country ); | 1343 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); | 1344 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", | 1345 //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), | 1346 // (!contact->business_po_box) ? "" : rfc2426_escape(contact->business_po_box), |
1348 // "", // extended Address | 1347 // "", // extended Address |
1349 // (!contact->business_street) ? "" : rfc2426_escape(contact->business_street), | 1348 // (!contact->business_street) ? "" : rfc2426_escape(contact->business_street), |
1350 // (!contact->business_city) ? "" : rfc2426_escape(contact->business_city), | 1349 // (!contact->business_city) ? "" : rfc2426_escape(contact->business_city), |
1351 // (!contact->business_state) ? "" : rfc2426_escape(contact->business_state), | 1350 // (!contact->business_state) ? "" : rfc2426_escape(contact->business_state), |
1352 // (!contact->business_postal_code) ? "" : rfc2426_escape(contact->business_postal_code), | 1351 // (!contact->business_postal_code) ? "" : rfc2426_escape(contact->business_postal_code), |
1353 // (!contact->business_country) ? "" : rfc2426_escape(contact->business_country)); | 1352 // (!contact->business_country) ? "" : rfc2426_escape(contact->business_country)); |
1354 fprintf(f_output, "LABEL;TYPE=work:%s\n", rfc2426_escape(contact->business_address)); | 1353 fprintf(f_output, "LABEL;TYPE=work:%s\n", rfc2426_escape(contact->business_address)); |