comparison src/readpst.c @ 300:47abe56076da

embedded rfc822 messages might contain rtf encoded bodies
author Carl Byington <carl@five-ten-sg.com>
date Fri, 04 Nov 2011 14:09:50 -0700
parents 201464dd356e
children 5338d93889aa
comparison
equal deleted inserted replaced
299:1ddc61fd6189 300:47abe56076da
42 void mk_separate_file(struct file_ll *f, char *extension); 42 void mk_separate_file(struct file_ll *f, char *extension);
43 void close_separate_file(struct file_ll *f); 43 void close_separate_file(struct file_ll *f);
44 char* my_stristr(char *haystack, char *needle); 44 char* my_stristr(char *haystack, char *needle);
45 void check_filename(char *fname); 45 void check_filename(char *fname);
46 void write_separate_attachment(char f_name[], pst_item_attach* attach, int attach_num, pst_file* pst); 46 void write_separate_attachment(char f_name[], pst_item_attach* attach, int attach_num, pst_file* pst);
47 void write_embedded_message(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pf, char** extra_mime_headers); 47 void write_embedded_message(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pf, int save_rtf, char** extra_mime_headers);
48 void write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst); 48 void write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst);
49 int valid_headers(char *header); 49 int valid_headers(char *header);
50 void header_has_field(char *header, char *field, int *flag); 50 void header_has_field(char *header, char *field, int *flag);
51 void header_get_subfield(char *field, const char *subfield, char *body_subfield, size_t size_subfield); 51 void header_get_subfield(char *field, const char *subfield, char *body_subfield, size_t size_subfield);
52 char* header_get_field(char *header, char *field); 52 char* header_get_field(char *header, char *field);
604 DEBUG_INIT(d_log, NULL); 604 DEBUG_INIT(d_log, NULL);
605 #endif 605 #endif
606 DEBUG_ENT("main"); 606 DEBUG_ENT("main");
607 607
608 if (output_mode != OUTPUT_QUIET) printf("Opening PST file and indexes...\n"); 608 if (output_mode != OUTPUT_QUIET) printf("Opening PST file and indexes...\n");
609
610 RET_DERROR(pst_open(&pstfile, fname, default_charset), 1, ("Error opening File\n")); 609 RET_DERROR(pst_open(&pstfile, fname, default_charset), 1, ("Error opening File\n"));
611 RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n")); 610 RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n"));
612 611
613 pst_load_extended_attributes(&pstfile); 612 pst_load_extended_attributes(&pstfile);
614 613
1048 if (temp) free(temp); 1047 if (temp) free(temp);
1049 DEBUG_RET(); 1048 DEBUG_RET();
1050 } 1049 }
1051 1050
1052 1051
1053 void write_embedded_message(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pf, char** extra_mime_headers) 1052 void write_embedded_message(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pf, int save_rtf, char** extra_mime_headers)
1054 { 1053 {
1055 pst_index_ll *ptr; 1054 pst_index_ll *ptr;
1056 DEBUG_ENT("write_embedded_message"); 1055 DEBUG_ENT("write_embedded_message");
1057 ptr = pst_getID(pf, attach->i_id); 1056 ptr = pst_getID(pf, attach->i_id);
1058 1057
1081 if (!item->email) { 1080 if (!item->email) {
1082 DEBUG_WARN(("write_embedded_message: pst_parse_item returned type %d, not an email message", item->type)); 1081 DEBUG_WARN(("write_embedded_message: pst_parse_item returned type %d, not an email message", item->type));
1083 } else { 1082 } else {
1084 fprintf(f_output, "\n--%s\n", boundary); 1083 fprintf(f_output, "\n--%s\n", boundary);
1085 fprintf(f_output, "Content-Type: %s\n\n", attach->mimetype.str); 1084 fprintf(f_output, "Content-Type: %s\n\n", attach->mimetype.str);
1086 write_normal_email(f_output, "", item, MODE_NORMAL, 0, pf, 0, extra_mime_headers); 1085 write_normal_email(f_output, "", item, MODE_NORMAL, 0, pf, save_rtf, extra_mime_headers);
1087 } 1086 }
1088 pst_freeItem(item); 1087 pst_freeItem(item);
1089 } 1088 }
1090 1089
1091 DEBUG_RET(); 1090 DEBUG_RET();
1732 free(attach->mimetype.str); 1731 free(attach->mimetype.str);
1733 } 1732 }
1734 attach->mimetype.str = strdup(RFC822); 1733 attach->mimetype.str = strdup(RFC822);
1735 attach->mimetype.is_utf8 = 1; 1734 attach->mimetype.is_utf8 = 1;
1736 find_rfc822_headers(extra_mime_headers); 1735 find_rfc822_headers(extra_mime_headers);
1737 write_embedded_message(f_output, attach, boundary, pst, extra_mime_headers); 1736 write_embedded_message(f_output, attach, boundary, pst, save_rtf, extra_mime_headers);
1738 } 1737 }
1739 else if (attach->data.data || attach->i_id) { 1738 else if (attach->data.data || attach->i_id) {
1740 if (mode == MODE_SEPARATE && !mode_MH) 1739 if (mode == MODE_SEPARATE && !mode_MH)
1741 write_separate_attachment(f_name, attach, ++attach_num, pst); 1740 write_separate_attachment(f_name, attach, ++attach_num, pst);
1742 else 1741 else