Mercurial > libpst
comparison src/readpst.c @ 28:51d826f31329
more cleanup from Arne, document 7c block format
author | carl |
---|---|
date | Sat, 25 Feb 2006 16:03:45 -0800 |
parents | 9eeba3f4ca4b |
children | b88ceb81dba2 |
comparison
equal
deleted
inserted
replaced
27:99e6b70cdfb3 | 28:51d826f31329 |
---|---|
916 } | 916 } |
917 | 917 |
918 void write_inline_attachment(FILE* f_output, pst_item_attach* current_attach, char boundary[], pst_file* pst) | 918 void write_inline_attachment(FILE* f_output, pst_item_attach* current_attach, char boundary[], pst_file* pst) |
919 { | 919 { |
920 char *enc; // base64 encoded attachment | 920 char *enc; // base64 encoded attachment |
921 DEBUG_MAIN(("write_inline_attachment: Attachment Size is %i\n", item->current_attach->size)); | 921 DEBUG_MAIN(("write_inline_attachment: Attachment Size is %i\n", current_attach->size)); |
922 DEBUG_MAIN(("write_inline_attachment: Attachment Pointer is %p\n", item->current_attach->data)); | 922 DEBUG_MAIN(("write_inline_attachment: Attachment Pointer is %p\n", current_attach->data)); |
923 if (current_attach->data != NULL) { | 923 if (current_attach->data != NULL) { |
924 if ((enc = base64_encode (current_attach->data, current_attach->size)) == NULL) { | 924 if ((enc = base64_encode (current_attach->data, current_attach->size)) == NULL) { |
925 DEBUG_MAIN(("write_inline_attachment: ERROR base64_encode returned NULL. Must have failed\n")); | 925 DEBUG_MAIN(("write_inline_attachment: ERROR base64_encode returned NULL. Must have failed\n")); |
926 return; | 926 return; |
927 } | 927 } |
955 char *boundary = NULL; // the boundary marker between multipart sections | 955 char *boundary = NULL; // the boundary marker between multipart sections |
956 char *temp = NULL; | 956 char *temp = NULL; |
957 int attach_num, base64_body = 0; | 957 int attach_num, base64_body = 0; |
958 time_t em_time; | 958 time_t em_time; |
959 char *c_time; | 959 char *c_time; |
960 pst_item_attach* current_attach; | |
960 | 961 |
961 // convert the sent date if it exists, or set it to a fixed date | 962 // convert the sent date if it exists, or set it to a fixed date |
962 if (item->email->sent_date != NULL) { | 963 if (item->email->sent_date != NULL) { |
963 em_time = fileTimeToUnixTime(item->email->sent_date, 0); | 964 em_time = fileTimeToUnixTime(item->email->sent_date, 0); |
964 c_time = ctime(&em_time); | 965 c_time = ctime(&em_time); |
1152 write_email_body(f_output, item->email->htmlbody); | 1153 write_email_body(f_output, item->email->htmlbody); |
1153 } | 1154 } |
1154 | 1155 |
1155 if (item->email->rtf_compressed != NULL) { | 1156 if (item->email->rtf_compressed != NULL) { |
1156 DEBUG_MAIN(("Adding RTF body as attachment\n")); | 1157 DEBUG_MAIN(("Adding RTF body as attachment\n")); |
1157 item->current_attach = (pst_item_attach*)xmalloc(sizeof(pst_item_attach)); | 1158 current_attach = (pst_item_attach*)xmalloc(sizeof(pst_item_attach)); |
1158 memset(item->current_attach, 0, sizeof(pst_item_attach)); | 1159 memset(current_attach, 0, sizeof(pst_item_attach)); |
1159 item->current_attach->next = item->attach; | 1160 current_attach->next = item->attach; |
1160 item->attach = item->current_attach; | 1161 item->attach = current_attach; |
1161 item->current_attach->data = lzfu_decompress(item->email->rtf_compressed); | 1162 current_attach->data = lzfu_decompress(item->email->rtf_compressed); |
1162 item->current_attach->filename2 = xmalloc(strlen(RTF_ATTACH_NAME)+2); | 1163 current_attach->filename2 = xmalloc(strlen(RTF_ATTACH_NAME)+2); |
1163 strcpy(item->current_attach->filename2, RTF_ATTACH_NAME); | 1164 strcpy(current_attach->filename2, RTF_ATTACH_NAME); |
1164 item->current_attach->mimetype = xmalloc(strlen(RTF_ATTACH_TYPE)+2); | 1165 current_attach->mimetype = xmalloc(strlen(RTF_ATTACH_TYPE)+2); |
1165 strcpy(item->current_attach->mimetype, RTF_ATTACH_TYPE); | 1166 strcpy(current_attach->mimetype, RTF_ATTACH_TYPE); |
1166 memcpy(&(item->current_attach->size), item->email->rtf_compressed+sizeof(int32_t), sizeof(int32_t)); | 1167 memcpy(&(current_attach->size), item->email->rtf_compressed+sizeof(int32_t), sizeof(int32_t)); |
1167 LE32_CPU(item->current_attach->size); | 1168 LE32_CPU(current_attach->size); |
1168 // item->email->rtf_compressed = ; | 1169 // item->email->rtf_compressed = ; |
1169 // attach_num++; | 1170 // attach_num++; |
1170 } | 1171 } |
1171 if (item->email->encrypted_body || item->email->encrypted_htmlbody) { | 1172 if (item->email->encrypted_body || item->email->encrypted_htmlbody) { |
1172 // if either the body or htmlbody is encrypted, add them as attachments | 1173 // if either the body or htmlbody is encrypted, add them as attachments |
1173 if (item->email->encrypted_body) { | 1174 if (item->email->encrypted_body) { |
1174 DEBUG_MAIN(("Adding Encrypted Body as attachment\n")); | 1175 DEBUG_MAIN(("Adding Encrypted Body as attachment\n")); |
1175 item->current_attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach)); | 1176 current_attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach)); |
1176 memset(item->current_attach, 0, sizeof(pst_item_attach)); | 1177 memset(current_attach, 0, sizeof(pst_item_attach)); |
1177 item->current_attach->next = item->attach; | 1178 current_attach->next = item->attach; |
1178 item->attach = item->current_attach; | 1179 item->attach = current_attach; |
1179 | 1180 |
1180 item->current_attach->data = item->email->encrypted_body; | 1181 current_attach->data = item->email->encrypted_body; |
1181 item->current_attach->size = item->email->encrypted_body_size; | 1182 current_attach->size = item->email->encrypted_body_size; |
1182 item->email->encrypted_body = NULL; | 1183 item->email->encrypted_body = NULL; |
1183 } | 1184 } |
1184 if (item->email->encrypted_htmlbody) { | 1185 if (item->email->encrypted_htmlbody) { |
1185 DEBUG_MAIN(("Adding encrypted HTML body as attachment\n")); | 1186 DEBUG_MAIN(("Adding encrypted HTML body as attachment\n")); |
1186 item->current_attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach)); | 1187 current_attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach)); |
1187 memset(item->current_attach, 0, sizeof(pst_item_attach)); | 1188 memset(current_attach, 0, sizeof(pst_item_attach)); |
1188 item->current_attach->next = item->attach; | 1189 current_attach->next = item->attach; |
1189 item->attach = item->current_attach; | 1190 item->attach = current_attach; |
1190 | 1191 |
1191 item->current_attach->data = item->email->encrypted_htmlbody; | 1192 current_attach->data = item->email->encrypted_htmlbody; |
1192 item->current_attach->size = item->email->encrypted_htmlbody_size; | 1193 current_attach->size = item->email->encrypted_htmlbody_size; |
1193 item->email->encrypted_htmlbody = NULL; | 1194 item->email->encrypted_htmlbody = NULL; |
1194 } | 1195 } |
1195 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"); | 1196 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"); |
1196 } | 1197 } |
1197 // attachments | 1198 // attachments |
1198 attach_num = 0; | 1199 attach_num = 0; |
1199 for(item->current_attach = item->attach; | 1200 for(current_attach = item->attach; |
1200 item->current_attach; | 1201 current_attach; |
1201 item->current_attach = item->current_attach->next) { | 1202 current_attach = current_attach->next) { |
1202 DEBUG_MAIN(("write_normal_email: Attempting Attachment encoding\n")); | 1203 DEBUG_MAIN(("write_normal_email: Attempting Attachment encoding\n")); |
1203 if (item->current_attach->data == NULL) { | 1204 if (current_attach->data == NULL) { |
1204 DEBUG_MAIN(("write_normal_email: Data of attachment is NULL!. Size is supposed to be %i\n", item->current_attach->size)); | 1205 DEBUG_MAIN(("write_normal_email: Data of attachment is NULL!. Size is supposed to be %i\n", current_attach->size)); |
1205 } | 1206 } |
1206 attach_num++; | 1207 attach_num++; |
1207 if (mode == MODE_SEPERATE && !mode_MH) | 1208 if (mode == MODE_SEPERATE && !mode_MH) |
1208 write_separate_attachment(f_name, item->current_attach, attach_num, pst); | 1209 write_separate_attachment(f_name, current_attach, attach_num, pst); |
1209 else | 1210 else |
1210 write_inline_attachment(f_output, item->current_attach, boundary, pst); | 1211 write_inline_attachment(f_output, current_attach, boundary, pst); |
1211 } | 1212 } |
1212 if (mode != MODE_SEPERATE) { /* do not add a boundary after the last attachment for mode_MH */ | 1213 if (mode != MODE_SEPERATE) { /* do not add a boundary after the last attachment for mode_MH */ |
1213 DEBUG_MAIN(("write_normal_email: Writing buffer between emails\n")); | 1214 DEBUG_MAIN(("write_normal_email: Writing buffer between emails\n")); |
1214 if (boundary) | 1215 if (boundary) |
1215 fprintf(f_output, "\n--%s--\n", boundary); | 1216 fprintf(f_output, "\n--%s--\n", boundary); |