comparison src/readpst.c @ 143:fdc58ad2c758 stable-0-6-28

fix embedded rfc822 messages with attachments
author Carl Byington <carl@five-ten-sg.com>
date Tue, 24 Feb 2009 12:33:49 -0800
parents 2189a6b8134e
children 0695de3b5a98
comparison
equal deleted inserted replaced
142:2189a6b8134e 143:fdc58ad2c758
136 ff.skip_count++; 136 ff.skip_count++;
137 } 137 }
138 else { 138 else {
139 DEBUG_MAIN(("main: Desc Email ID %#"PRIx64" [d_ptr->id = %#"PRIx64"]\n", d_ptr->desc->id, d_ptr->id)); 139 DEBUG_MAIN(("main: Desc Email ID %#"PRIx64" [d_ptr->id = %#"PRIx64"]\n", d_ptr->desc->id, d_ptr->id));
140 140
141 item = pst_parse_item(&pstfile, d_ptr); 141 item = pst_parse_item(&pstfile, d_ptr, NULL);
142 DEBUG_MAIN(("main: About to process item\n")); 142 DEBUG_MAIN(("main: About to process item\n"));
143 if (item && item->email && item->email->subject && item->email->subject->subj) { 143 if (item && item->email && item->email->subject && item->email->subject->subj) {
144 DEBUG_EMAIL(("item->email->subject->subj = %s\n", item->email->subject->subj)); 144 DEBUG_EMAIL(("item->email->subject->subj = %s\n", item->email->subject->subj));
145 } 145 }
146 if (item) { 146 if (item) {
358 } 358 }
359 359
360 if (output_mode != OUTPUT_QUIET) printf("About to start processing first record...\n"); 360 if (output_mode != OUTPUT_QUIET) printf("About to start processing first record...\n");
361 361
362 d_ptr = pstfile.d_head; // first record is main record 362 d_ptr = pstfile.d_head; // first record is main record
363 item = pst_parse_item(&pstfile, d_ptr); 363 item = pst_parse_item(&pstfile, d_ptr, NULL);
364 if (!item || !item->message_store) { 364 if (!item || !item->message_store) {
365 DEBUG_RET(); 365 DEBUG_RET();
366 DIE(("main: Could not get root record\n")); 366 DIE(("main: Could not get root record\n"));
367 } 367 }
368 368
744 pst_index_ll *ptr; 744 pst_index_ll *ptr;
745 DEBUG_ENT("write_embedded_message"); 745 DEBUG_ENT("write_embedded_message");
746 fprintf(f_output, "\n--%s\n", boundary); 746 fprintf(f_output, "\n--%s\n", boundary);
747 fprintf(f_output, "Content-Type: %s\n\n", attach->mimetype); 747 fprintf(f_output, "Content-Type: %s\n\n", attach->mimetype);
748 ptr = pst_getID(pf, attach->id_val); 748 ptr = pst_getID(pf, attach->id_val);
749 pst_num_array *list = pst_parse_block(pf, ptr->id, NULL, NULL); 749
750 if (list) { 750 pst_desc_ll d_ptr;
751 pst_item *item = (pst_item*) xmalloc(sizeof(pst_item)); 751 d_ptr.id = ptr->id;
752 memset(item, 0, sizeof(pst_item)); 752 d_ptr.parent_id = 0;
753 if (!pst_process(list, item, NULL)) { 753 d_ptr.list_index = NULL;
754 write_normal_email(f_output, "", item, MODE_NORMAL, 0, pf, 0, extra_mime_headers); 754 d_ptr.desc = ptr;
755 } 755 d_ptr.no_child - 0;
756 pst_freeItem(item); 756 d_ptr.prev = NULL;
757 pst_free_list(list); 757 d_ptr.next = NULL;
758 } 758 d_ptr.parent = NULL;
759 d_ptr.child = NULL;
760 d_ptr.child_tail = NULL;
761
762 pst_item *item = pst_parse_item(pf, &d_ptr, attach->id2_head);
763 write_normal_email(f_output, "", item, MODE_NORMAL, 0, pf, 0, extra_mime_headers);
764 pst_freeItem(item);
765
759 DEBUG_RET(); 766 DEBUG_RET();
760 } 767 }
761 768
762 769
763 void write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst) 770 void write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst)
1023 if (needfree) free(needfree); 1030 if (needfree) free(needfree);
1024 DEBUG_RET(); 1031 DEBUG_RET();
1025 } 1032 }
1026 1033
1027 1034
1035 const char* codepage(int cp);
1028 const char* codepage(int cp) { 1036 const char* codepage(int cp) {
1029 static char buffer[20]; 1037 static char buffer[20];
1030 switch (cp) { 1038 switch (cp) {
1031 case 932 : return "iso-2022-jp"; 1039 case 932 : return "iso-2022-jp";
1032 case 936 : return "gb2313"; 1040 case 936 : return "gb2313";
1048 case 51932 : return "euc-jp"; 1056 case 51932 : return "euc-jp";
1049 case 51949 : return "euc-kr"; 1057 case 51949 : return "euc-kr";
1050 case 65000 : return "utf-7"; 1058 case 65000 : return "utf-7";
1051 case 65001 : return "utf-8"; 1059 case 65001 : return "utf-8";
1052 default : 1060 default :
1053 snprintf(buffer, sizeof(buffer), "cp%d", cp); 1061 snprintf(buffer, sizeof(buffer), "windows-%d", cp);
1054 return buffer; 1062 return buffer;
1055 } 1063 }
1056 return NULL; 1064 return NULL;
1057 } 1065 }
1058 1066