comparison src/readpst.c @ 304:5338d93889aa

preserve bcc headers, document -C switch to set default character set, space after colon is not required in header fields
author Carl Byington <carl@five-ten-sg.com>
date Tue, 08 May 2012 10:52:24 -0700
parents 47abe56076da
children c4537664ff50
comparison
equal deleted inserted replaced
303:23915d34387f 304:5338d93889aa
706 DEBUG_ENT("usage"); 706 DEBUG_ENT("usage");
707 version(); 707 version();
708 printf("Usage: %s [OPTIONS] {PST FILENAME}\n", prog_name); 708 printf("Usage: %s [OPTIONS] {PST FILENAME}\n", prog_name);
709 printf("OPTIONS:\n"); 709 printf("OPTIONS:\n");
710 printf("\t-V\t- Version. Display program version\n"); 710 printf("\t-V\t- Version. Display program version\n");
711 printf("\t-C charset\t- character set for items with unspecified character set\n"); 711 printf("\t-C charset\t- character set for items with an unspecified character set\n");
712 printf("\t-D\t- Include deleted items in output\n"); 712 printf("\t-D\t- Include deleted items in output\n");
713 printf("\t-M\t- Write emails in the MH (rfc822) format\n"); 713 printf("\t-M\t- Write emails in the MH (rfc822) format\n");
714 printf("\t-S\t- Separate. Write emails in the separate format\n"); 714 printf("\t-S\t- Separate. Write emails in the separate format\n");
715 printf("\t-b\t- Don't save RTF-Body attachments\n"); 715 printf("\t-b\t- Don't save RTF-Body attachments\n");
716 printf("\t-c[v|l]\t- Set the Contact output mode. -cv = VCard, -cl = EMail list\n"); 716 printf("\t-c[v|l]\t- Set the Contact output mode. -cv = VCard, -cl = EMail list\n");
1303 char *headers = *extra_mime_headers; 1303 char *headers = *extra_mime_headers;
1304 if (headers) { 1304 if (headers) {
1305 char *temp, *t; 1305 char *temp, *t;
1306 while ((temp = strstr(headers, "\n\n"))) { 1306 while ((temp = strstr(headers, "\n\n"))) {
1307 temp[1] = '\0'; 1307 temp[1] = '\0';
1308 t = header_get_field(headers, "\nContent-Type: "); 1308 t = header_get_field(headers, "\nContent-Type:");
1309 if (t) { 1309 if (t) {
1310 t++; 1310 t++;
1311 DEBUG_INFO(("found content type header\n")); 1311 DEBUG_INFO(("found content type header\n"));
1312 char *n = strchr(t, '\n'); 1312 char *n = strchr(t, '\n');
1313 char *s = strstr(t, ": "); 1313 char *s = strstr(t, ": ");
1491 if (!*extra_mime_headers) *extra_mime_headers = temp+2; 1491 if (!*extra_mime_headers) *extra_mime_headers = temp+2;
1492 DEBUG_INFO(("Found extra mime headers\n%s\n", temp+2)); 1492 DEBUG_INFO(("Found extra mime headers\n%s\n", temp+2));
1493 } 1493 }
1494 1494
1495 // Check if the headers have all the necessary fields 1495 // Check if the headers have all the necessary fields
1496 header_has_field(headers, "\nFrom: ", &has_from); 1496 header_has_field(headers, "\nFrom:", &has_from);
1497 header_has_field(headers, "\nTo: ", &has_to); 1497 header_has_field(headers, "\nTo:", &has_to);
1498 header_has_field(headers, "\nSubject: ", &has_subject); 1498 header_has_field(headers, "\nSubject:", &has_subject);
1499 header_has_field(headers, "\nDate: ", &has_date); 1499 header_has_field(headers, "\nDate:", &has_date);
1500 header_has_field(headers, "\nCC: ", &has_cc); 1500 header_has_field(headers, "\nCC:", &has_cc);
1501 header_has_field(headers, "\nMessage-Id: ", &has_msgid); 1501 header_has_field(headers, "\nMessage-Id:", &has_msgid);
1502 1502
1503 // look for charset and report-type in Content-Type header 1503 // look for charset and report-type in Content-Type header
1504 t = header_get_field(headers, "\nContent-Type: "); 1504 t = header_get_field(headers, "\nContent-Type:");
1505 header_get_subfield(t, "charset", body_charset, sizeof(body_charset)); 1505 header_get_subfield(t, "charset", body_charset, sizeof(body_charset));
1506 header_get_subfield(t, "report-type", body_report, sizeof(body_report)); 1506 header_get_subfield(t, "report-type", body_report, sizeof(body_report));
1507 1507
1508 // derive a proper sender email address 1508 // derive a proper sender email address
1509 if (!sender_known) { 1509 if (!sender_known) {
1510 t = header_get_field(headers, "\nFrom: "); 1510 t = header_get_field(headers, "\nFrom:");
1511 if (t) { 1511 if (t) {
1512 // assume address is on the first line, rather than on a continuation line 1512 // assume address is on the first line, rather than on a continuation line
1513 t++; 1513 t++;
1514 char *n = strchr(t, '\n'); 1514 char *n = strchr(t, '\n');
1515 char *s = strchr(t, '<'); 1515 char *s = strchr(t, '<');
1523 } 1523 }
1524 } 1524 }
1525 1525
1526 // Strip out the mime headers and some others that we don't want to emit 1526 // Strip out the mime headers and some others that we don't want to emit
1527 header_strip_field(headers, "\nMicrosoft Mail Internet Headers"); 1527 header_strip_field(headers, "\nMicrosoft Mail Internet Headers");
1528 header_strip_field(headers, "\nMIME-Version: "); 1528 header_strip_field(headers, "\nMIME-Version:");
1529 header_strip_field(headers, "\nContent-Type: "); 1529 header_strip_field(headers, "\nContent-Type:");
1530 header_strip_field(headers, "\nContent-Transfer-Encoding: "); 1530 header_strip_field(headers, "\nContent-Transfer-Encoding:");
1531 header_strip_field(headers, "\nContent-class: "); 1531 header_strip_field(headers, "\nContent-class:");
1532 header_strip_field(headers, "\nX-MimeOLE: "); 1532 header_strip_field(headers, "\nX-MimeOLE:");
1533 header_strip_field(headers, "\nBcc:"); 1533 header_strip_field(headers, "\nX-From_:");
1534 header_strip_field(headers, "\nX-From_: ");
1535 } 1534 }
1536 1535
1537 DEBUG_INFO(("About to print Header\n")); 1536 DEBUG_INFO(("About to print Header\n"));
1538 1537
1539 if (item && item->subject.str) { 1538 if (item && item->subject.str) {