comparison src/readpst.c @ 211:94bde95d7e18

the shared library interface should now be thread safe
author Carl Byington <carl@five-ten-sg.com>
date Mon, 08 Jun 2009 11:49:39 -0700
parents 5f3fa53cb0e1
children 8e17efed33c1
comparison
equal deleted inserted replaced
210:2d1111fd70cf 211:94bde95d7e18
1216 void write_normal_email(FILE* f_output, char f_name[], pst_item* item, int mode, int mode_MH, pst_file* pst, int save_rtf, char** extra_mime_headers) 1216 void write_normal_email(FILE* f_output, char f_name[], pst_item* item, int mode, int mode_MH, pst_file* pst, int save_rtf, char** extra_mime_headers)
1217 { 1217 {
1218 char boundary[60]; 1218 char boundary[60];
1219 char altboundary[66]; 1219 char altboundary[66];
1220 char *altboundaryp = NULL; 1220 char *altboundaryp = NULL;
1221 char body_charset[60]; 1221 char body_charset[30];
1222 char buffer_charset[30];
1222 char body_report[60]; 1223 char body_report[60];
1223 char sender[60]; 1224 char sender[60];
1224 int sender_known = 0; 1225 int sender_known = 0;
1225 char *temp = NULL; 1226 char *temp = NULL;
1226 time_t em_time; 1227 time_t em_time;
1232 1233
1233 pst_convert_utf8_null(item, &item->email->header); 1234 pst_convert_utf8_null(item, &item->email->header);
1234 headers = (item->email->header.str) ? item->email->header.str : *extra_mime_headers; 1235 headers = (item->email->header.str) ? item->email->header.str : *extra_mime_headers;
1235 1236
1236 // setup default body character set and report type 1237 // setup default body character set and report type
1237 strncpy(body_charset, pst_default_charset(item), sizeof(body_charset)); 1238 strncpy(body_charset, pst_default_charset(item, sizeof(buffer_charset), buffer_charset), sizeof(body_charset));
1238 body_charset[sizeof(body_charset)-1] = '\0'; 1239 body_charset[sizeof(body_charset)-1] = '\0';
1239 body_report[0] = '\0'; 1240 body_report[0] = '\0';
1240 1241
1241 // setup default sender 1242 // setup default sender
1242 pst_convert_utf8(item, &item->email->sender_address); 1243 pst_convert_utf8(item, &item->email->sender_address);
1504 fprintf(f_output, "\n--%s--\n\n", boundary); 1505 fprintf(f_output, "\n--%s--\n\n", boundary);
1505 DEBUG_RET(); 1506 DEBUG_RET();
1506 } 1507 }
1507 1508
1508 1509
1509 void write_vcard(FILE* f_output, pst_item *item, pst_item_contact* contact, char comment[]) 1510 void write_vcard(FILE* f_output, pst_item* item, pst_item_contact* contact, char comment[])
1510 { 1511 {
1511 char time_buffer[30]; 1512 char* result = NULL;
1513 size_t resultlen = 0;
1514 char time_buffer[30];
1512 // We can only call rfc escape once per printf, since the second call 1515 // We can only call rfc escape once per printf, since the second call
1513 // may free the buffer returned by the first call. 1516 // may free the buffer returned by the first call.
1514 // I had tried to place those into a single printf - Carl. 1517 // I had tried to place those into a single printf - Carl.
1515 1518
1516 DEBUG_ENT("write_vcard"); 1519 DEBUG_ENT("write_vcard");
1568 pst_convert_utf8_null(item, &contact->assistant_phone); 1571 pst_convert_utf8_null(item, &contact->assistant_phone);
1569 pst_convert_utf8_null(item, &contact->company_name); 1572 pst_convert_utf8_null(item, &contact->company_name);
1570 1573
1571 // the specification I am following is (hopefully) RFC2426 vCard Mime Directory Profile 1574 // the specification I am following is (hopefully) RFC2426 vCard Mime Directory Profile
1572 fprintf(f_output, "BEGIN:VCARD\n"); 1575 fprintf(f_output, "BEGIN:VCARD\n");
1573 fprintf(f_output, "FN:%s\n", pst_rfc2426_escape(contact->fullname.str)); 1576 fprintf(f_output, "FN:%s\n", pst_rfc2426_escape(contact->fullname.str, &result, &resultlen));
1574 1577
1575 //fprintf(f_output, "N:%s;%s;%s;%s;%s\n", 1578 //fprintf(f_output, "N:%s;%s;%s;%s;%s\n",
1576 fprintf(f_output, "N:%s;", (!contact->surname.str) ? "" : pst_rfc2426_escape(contact->surname.str)); 1579 fprintf(f_output, "N:%s;", (!contact->surname.str) ? "" : pst_rfc2426_escape(contact->surname.str, &result, &resultlen));
1577 fprintf(f_output, "%s;", (!contact->first_name.str) ? "" : pst_rfc2426_escape(contact->first_name.str)); 1580 fprintf(f_output, "%s;", (!contact->first_name.str) ? "" : pst_rfc2426_escape(contact->first_name.str, &result, &resultlen));
1578 fprintf(f_output, "%s;", (!contact->middle_name.str) ? "" : pst_rfc2426_escape(contact->middle_name.str)); 1581 fprintf(f_output, "%s;", (!contact->middle_name.str) ? "" : pst_rfc2426_escape(contact->middle_name.str, &result, &resultlen));
1579 fprintf(f_output, "%s;", (!contact->display_name_prefix.str) ? "" : pst_rfc2426_escape(contact->display_name_prefix.str)); 1582 fprintf(f_output, "%s;", (!contact->display_name_prefix.str) ? "" : pst_rfc2426_escape(contact->display_name_prefix.str, &result, &resultlen));
1580 fprintf(f_output, "%s\n", (!contact->suffix.str) ? "" : pst_rfc2426_escape(contact->suffix.str)); 1583 fprintf(f_output, "%s\n", (!contact->suffix.str) ? "" : pst_rfc2426_escape(contact->suffix.str, &result, &resultlen));
1581 1584
1582 if (contact->nickname.str) 1585 if (contact->nickname.str)
1583 fprintf(f_output, "NICKNAME:%s\n", pst_rfc2426_escape(contact->nickname.str)); 1586 fprintf(f_output, "NICKNAME:%s\n", pst_rfc2426_escape(contact->nickname.str, &result, &resultlen));
1584 if (contact->address1.str) 1587 if (contact->address1.str)
1585 fprintf(f_output, "EMAIL:%s\n", pst_rfc2426_escape(contact->address1.str)); 1588 fprintf(f_output, "EMAIL:%s\n", pst_rfc2426_escape(contact->address1.str, &result, &resultlen));
1586 if (contact->address2.str) 1589 if (contact->address2.str)
1587 fprintf(f_output, "EMAIL:%s\n", pst_rfc2426_escape(contact->address2.str)); 1590 fprintf(f_output, "EMAIL:%s\n", pst_rfc2426_escape(contact->address2.str, &result, &resultlen));
1588 if (contact->address3.str) 1591 if (contact->address3.str)
1589 fprintf(f_output, "EMAIL:%s\n", pst_rfc2426_escape(contact->address3.str)); 1592 fprintf(f_output, "EMAIL:%s\n", pst_rfc2426_escape(contact->address3.str, &result, &resultlen));
1590 if (contact->birthday) 1593 if (contact->birthday)
1591 fprintf(f_output, "BDAY:%s\n", pst_rfc2425_datetime_format(contact->birthday, sizeof(time_buffer), time_buffer)); 1594 fprintf(f_output, "BDAY:%s\n", pst_rfc2425_datetime_format(contact->birthday, sizeof(time_buffer), time_buffer));
1592 1595
1593 if (contact->home_address.str) { 1596 if (contact->home_address.str) {
1594 //fprintf(f_output, "ADR;TYPE=home:%s;%s;%s;%s;%s;%s;%s\n", 1597 //fprintf(f_output, "ADR;TYPE=home:%s;%s;%s;%s;%s;%s;%s\n",
1595 fprintf(f_output, "ADR;TYPE=home:%s;", (!contact->home_po_box.str) ? "" : pst_rfc2426_escape(contact->home_po_box.str)); 1598 fprintf(f_output, "ADR;TYPE=home:%s;", (!contact->home_po_box.str) ? "" : pst_rfc2426_escape(contact->home_po_box.str, &result, &resultlen));
1596 fprintf(f_output, "%s;", ""); // extended Address 1599 fprintf(f_output, "%s;", ""); // extended Address
1597 fprintf(f_output, "%s;", (!contact->home_street.str) ? "" : pst_rfc2426_escape(contact->home_street.str)); 1600 fprintf(f_output, "%s;", (!contact->home_street.str) ? "" : pst_rfc2426_escape(contact->home_street.str, &result, &resultlen));
1598 fprintf(f_output, "%s;", (!contact->home_city.str) ? "" : pst_rfc2426_escape(contact->home_city.str)); 1601 fprintf(f_output, "%s;", (!contact->home_city.str) ? "" : pst_rfc2426_escape(contact->home_city.str, &result, &resultlen));
1599 fprintf(f_output, "%s;", (!contact->home_state.str) ? "" : pst_rfc2426_escape(contact->home_state.str)); 1602 fprintf(f_output, "%s;", (!contact->home_state.str) ? "" : pst_rfc2426_escape(contact->home_state.str, &result, &resultlen));
1600 fprintf(f_output, "%s;", (!contact->home_postal_code.str) ? "" : pst_rfc2426_escape(contact->home_postal_code.str)); 1603 fprintf(f_output, "%s;", (!contact->home_postal_code.str) ? "" : pst_rfc2426_escape(contact->home_postal_code.str, &result, &resultlen));
1601 fprintf(f_output, "%s\n", (!contact->home_country.str) ? "" : pst_rfc2426_escape(contact->home_country.str)); 1604 fprintf(f_output, "%s\n", (!contact->home_country.str) ? "" : pst_rfc2426_escape(contact->home_country.str, &result, &resultlen));
1602 fprintf(f_output, "LABEL;TYPE=home:%s\n", pst_rfc2426_escape(contact->home_address.str)); 1605 fprintf(f_output, "LABEL;TYPE=home:%s\n", pst_rfc2426_escape(contact->home_address.str, &result, &resultlen));
1603 } 1606 }
1604 1607
1605 if (contact->business_address.str) { 1608 if (contact->business_address.str) {
1606 //fprintf(f_output, "ADR;TYPE=work:%s;%s;%s;%s;%s;%s;%s\n", 1609 //fprintf(f_output, "ADR;TYPE=work:%s;%s;%s;%s;%s;%s;%s\n",
1607 fprintf(f_output, "ADR;TYPE=work:%s;", (!contact->business_po_box.str) ? "" : pst_rfc2426_escape(contact->business_po_box.str)); 1610 fprintf(f_output, "ADR;TYPE=work:%s;", (!contact->business_po_box.str) ? "" : pst_rfc2426_escape(contact->business_po_box.str, &result, &resultlen));
1608 fprintf(f_output, "%s;", ""); // extended Address 1611 fprintf(f_output, "%s;", ""); // extended Address
1609 fprintf(f_output, "%s;", (!contact->business_street.str) ? "" : pst_rfc2426_escape(contact->business_street.str)); 1612 fprintf(f_output, "%s;", (!contact->business_street.str) ? "" : pst_rfc2426_escape(contact->business_street.str, &result, &resultlen));
1610 fprintf(f_output, "%s;", (!contact->business_city.str) ? "" : pst_rfc2426_escape(contact->business_city.str)); 1613 fprintf(f_output, "%s;", (!contact->business_city.str) ? "" : pst_rfc2426_escape(contact->business_city.str, &result, &resultlen));
1611 fprintf(f_output, "%s;", (!contact->business_state.str) ? "" : pst_rfc2426_escape(contact->business_state.str)); 1614 fprintf(f_output, "%s;", (!contact->business_state.str) ? "" : pst_rfc2426_escape(contact->business_state.str, &result, &resultlen));
1612 fprintf(f_output, "%s;", (!contact->business_postal_code.str) ? "" : pst_rfc2426_escape(contact->business_postal_code.str)); 1615 fprintf(f_output, "%s;", (!contact->business_postal_code.str) ? "" : pst_rfc2426_escape(contact->business_postal_code.str, &result, &resultlen));
1613 fprintf(f_output, "%s\n", (!contact->business_country.str) ? "" : pst_rfc2426_escape(contact->business_country.str)); 1616 fprintf(f_output, "%s\n", (!contact->business_country.str) ? "" : pst_rfc2426_escape(contact->business_country.str, &result, &resultlen));
1614 fprintf(f_output, "LABEL;TYPE=work:%s\n", pst_rfc2426_escape(contact->business_address.str)); 1617 fprintf(f_output, "LABEL;TYPE=work:%s\n", pst_rfc2426_escape(contact->business_address.str, &result, &resultlen));
1615 } 1618 }
1616 1619
1617 if (contact->other_address.str) { 1620 if (contact->other_address.str) {
1618 //fprintf(f_output, "ADR;TYPE=postal:%s;%s;%s;%s;%s;%s;%s\n", 1621 //fprintf(f_output, "ADR;TYPE=postal:%s;%s;%s;%s;%s;%s;%s\n",
1619 fprintf(f_output, "ADR;TYPE=postal:%s;",(!contact->other_po_box.str) ? "" : pst_rfc2426_escape(contact->other_po_box.str)); 1622 fprintf(f_output, "ADR;TYPE=postal:%s;",(!contact->other_po_box.str) ? "" : pst_rfc2426_escape(contact->other_po_box.str, &result, &resultlen));
1620 fprintf(f_output, "%s;", ""); // extended Address 1623 fprintf(f_output, "%s;", ""); // extended Address
1621 fprintf(f_output, "%s;", (!contact->other_street.str) ? "" : pst_rfc2426_escape(contact->other_street.str)); 1624 fprintf(f_output, "%s;", (!contact->other_street.str) ? "" : pst_rfc2426_escape(contact->other_street.str, &result, &resultlen));
1622 fprintf(f_output, "%s;", (!contact->other_city.str) ? "" : pst_rfc2426_escape(contact->other_city.str)); 1625 fprintf(f_output, "%s;", (!contact->other_city.str) ? "" : pst_rfc2426_escape(contact->other_city.str, &result, &resultlen));
1623 fprintf(f_output, "%s;", (!contact->other_state.str) ? "" : pst_rfc2426_escape(contact->other_state.str)); 1626 fprintf(f_output, "%s;", (!contact->other_state.str) ? "" : pst_rfc2426_escape(contact->other_state.str, &result, &resultlen));
1624 fprintf(f_output, "%s;", (!contact->other_postal_code.str) ? "" : pst_rfc2426_escape(contact->other_postal_code.str)); 1627 fprintf(f_output, "%s;", (!contact->other_postal_code.str) ? "" : pst_rfc2426_escape(contact->other_postal_code.str, &result, &resultlen));
1625 fprintf(f_output, "%s\n", (!contact->other_country.str) ? "" : pst_rfc2426_escape(contact->other_country.str)); 1628 fprintf(f_output, "%s\n", (!contact->other_country.str) ? "" : pst_rfc2426_escape(contact->other_country.str, &result, &resultlen));
1626 fprintf(f_output, "LABEL;TYPE=postal:%s\n", pst_rfc2426_escape(contact->other_address.str)); 1629 fprintf(f_output, "LABEL;TYPE=postal:%s\n", pst_rfc2426_escape(contact->other_address.str, &result, &resultlen));
1627 } 1630 }
1628 1631
1629 if (contact->business_fax.str) fprintf(f_output, "TEL;TYPE=work,fax:%s\n", pst_rfc2426_escape(contact->business_fax.str)); 1632 if (contact->business_fax.str) fprintf(f_output, "TEL;TYPE=work,fax:%s\n", pst_rfc2426_escape(contact->business_fax.str, &result, &resultlen));
1630 if (contact->business_phone.str) fprintf(f_output, "TEL;TYPE=work,voice:%s\n", pst_rfc2426_escape(contact->business_phone.str)); 1633 if (contact->business_phone.str) fprintf(f_output, "TEL;TYPE=work,voice:%s\n", pst_rfc2426_escape(contact->business_phone.str, &result, &resultlen));
1631 if (contact->business_phone2.str) fprintf(f_output, "TEL;TYPE=work,voice:%s\n", pst_rfc2426_escape(contact->business_phone2.str)); 1634 if (contact->business_phone2.str) fprintf(f_output, "TEL;TYPE=work,voice:%s\n", pst_rfc2426_escape(contact->business_phone2.str, &result, &resultlen));
1632 if (contact->car_phone.str) fprintf(f_output, "TEL;TYPE=car,voice:%s\n", pst_rfc2426_escape(contact->car_phone.str)); 1635 if (contact->car_phone.str) fprintf(f_output, "TEL;TYPE=car,voice:%s\n", pst_rfc2426_escape(contact->car_phone.str, &result, &resultlen));
1633 if (contact->home_fax.str) fprintf(f_output, "TEL;TYPE=home,fax:%s\n", pst_rfc2426_escape(contact->home_fax.str)); 1636 if (contact->home_fax.str) fprintf(f_output, "TEL;TYPE=home,fax:%s\n", pst_rfc2426_escape(contact->home_fax.str, &result, &resultlen));
1634 if (contact->home_phone.str) fprintf(f_output, "TEL;TYPE=home,voice:%s\n", pst_rfc2426_escape(contact->home_phone.str)); 1637 if (contact->home_phone.str) fprintf(f_output, "TEL;TYPE=home,voice:%s\n", pst_rfc2426_escape(contact->home_phone.str, &result, &resultlen));
1635 if (contact->home_phone2.str) fprintf(f_output, "TEL;TYPE=home,voice:%s\n", pst_rfc2426_escape(contact->home_phone2.str)); 1638 if (contact->home_phone2.str) fprintf(f_output, "TEL;TYPE=home,voice:%s\n", pst_rfc2426_escape(contact->home_phone2.str, &result, &resultlen));
1636 if (contact->isdn_phone.str) fprintf(f_output, "TEL;TYPE=isdn:%s\n", pst_rfc2426_escape(contact->isdn_phone.str)); 1639 if (contact->isdn_phone.str) fprintf(f_output, "TEL;TYPE=isdn:%s\n", pst_rfc2426_escape(contact->isdn_phone.str, &result, &resultlen));
1637 if (contact->mobile_phone.str) fprintf(f_output, "TEL;TYPE=cell,voice:%s\n", pst_rfc2426_escape(contact->mobile_phone.str)); 1640 if (contact->mobile_phone.str) fprintf(f_output, "TEL;TYPE=cell,voice:%s\n", pst_rfc2426_escape(contact->mobile_phone.str, &result, &resultlen));
1638 if (contact->other_phone.str) fprintf(f_output, "TEL;TYPE=msg:%s\n", pst_rfc2426_escape(contact->other_phone.str)); 1641 if (contact->other_phone.str) fprintf(f_output, "TEL;TYPE=msg:%s\n", pst_rfc2426_escape(contact->other_phone.str, &result, &resultlen));
1639 if (contact->pager_phone.str) fprintf(f_output, "TEL;TYPE=pager:%s\n", pst_rfc2426_escape(contact->pager_phone.str)); 1642 if (contact->pager_phone.str) fprintf(f_output, "TEL;TYPE=pager:%s\n", pst_rfc2426_escape(contact->pager_phone.str, &result, &resultlen));
1640 if (contact->primary_fax.str) fprintf(f_output, "TEL;TYPE=fax,pref:%s\n", pst_rfc2426_escape(contact->primary_fax.str)); 1643 if (contact->primary_fax.str) fprintf(f_output, "TEL;TYPE=fax,pref:%s\n", pst_rfc2426_escape(contact->primary_fax.str, &result, &resultlen));
1641 if (contact->primary_phone.str) fprintf(f_output, "TEL;TYPE=phone,pref:%s\n", pst_rfc2426_escape(contact->primary_phone.str)); 1644 if (contact->primary_phone.str) fprintf(f_output, "TEL;TYPE=phone,pref:%s\n", pst_rfc2426_escape(contact->primary_phone.str, &result, &resultlen));
1642 if (contact->radio_phone.str) fprintf(f_output, "TEL;TYPE=pcs:%s\n", pst_rfc2426_escape(contact->radio_phone.str)); 1645 if (contact->radio_phone.str) fprintf(f_output, "TEL;TYPE=pcs:%s\n", pst_rfc2426_escape(contact->radio_phone.str, &result, &resultlen));
1643 if (contact->telex.str) fprintf(f_output, "TEL;TYPE=bbs:%s\n", pst_rfc2426_escape(contact->telex.str)); 1646 if (contact->telex.str) fprintf(f_output, "TEL;TYPE=bbs:%s\n", pst_rfc2426_escape(contact->telex.str, &result, &resultlen));
1644 if (contact->job_title.str) fprintf(f_output, "TITLE:%s\n", pst_rfc2426_escape(contact->job_title.str)); 1647 if (contact->job_title.str) fprintf(f_output, "TITLE:%s\n", pst_rfc2426_escape(contact->job_title.str, &result, &resultlen));
1645 if (contact->profession.str) fprintf(f_output, "ROLE:%s\n", pst_rfc2426_escape(contact->profession.str)); 1648 if (contact->profession.str) fprintf(f_output, "ROLE:%s\n", pst_rfc2426_escape(contact->profession.str, &result, &resultlen));
1646 if (contact->assistant_name.str || contact->assistant_phone.str) { 1649 if (contact->assistant_name.str || contact->assistant_phone.str) {
1647 fprintf(f_output, "AGENT:BEGIN:VCARD\n"); 1650 fprintf(f_output, "AGENT:BEGIN:VCARD\n");
1648 if (contact->assistant_name.str) fprintf(f_output, "FN:%s\n", pst_rfc2426_escape(contact->assistant_name.str)); 1651 if (contact->assistant_name.str) fprintf(f_output, "FN:%s\n", pst_rfc2426_escape(contact->assistant_name.str, &result, &resultlen));
1649 if (contact->assistant_phone.str) fprintf(f_output, "TEL:%s\n", pst_rfc2426_escape(contact->assistant_phone.str)); 1652 if (contact->assistant_phone.str) fprintf(f_output, "TEL:%s\n", pst_rfc2426_escape(contact->assistant_phone.str, &result, &resultlen));
1650 } 1653 }
1651 if (contact->company_name.str) fprintf(f_output, "ORG:%s\n", pst_rfc2426_escape(contact->company_name.str)); 1654 if (contact->company_name.str) fprintf(f_output, "ORG:%s\n", pst_rfc2426_escape(contact->company_name.str, &result, &resultlen));
1652 if (comment) fprintf(f_output, "NOTE:%s\n", pst_rfc2426_escape(comment)); 1655 if (comment) fprintf(f_output, "NOTE:%s\n", pst_rfc2426_escape(comment, &result, &resultlen));
1653 1656
1654 fprintf(f_output, "VERSION: 3.0\n"); 1657 fprintf(f_output, "VERSION: 3.0\n");
1655 fprintf(f_output, "END:VCARD\n\n"); 1658 fprintf(f_output, "END:VCARD\n\n");
1659 if (result) free(result);
1656 DEBUG_RET(); 1660 DEBUG_RET();
1657 } 1661 }
1658 1662
1659 1663
1660 void write_journal(FILE* f_output, pst_item* item) 1664 void write_journal(FILE* f_output, pst_item* item)
1661 { 1665 {
1662 char time_buffer[30]; 1666 char* result = NULL;
1667 size_t resultlen = 0;
1668 char time_buffer[30];
1663 pst_item_journal* journal = item->journal; 1669 pst_item_journal* journal = item->journal;
1664 1670
1665 // make everything utf8 1671 // make everything utf8
1666 pst_convert_utf8_null(item, &item->subject); 1672 pst_convert_utf8_null(item, &item->subject);
1667 pst_convert_utf8_null(item, &item->body); 1673 pst_convert_utf8_null(item, &item->body);
1671 if (item->create_date) 1677 if (item->create_date)
1672 fprintf(f_output, "CREATED:%s\n", pst_rfc2445_datetime_format(item->create_date, sizeof(time_buffer), time_buffer)); 1678 fprintf(f_output, "CREATED:%s\n", pst_rfc2445_datetime_format(item->create_date, sizeof(time_buffer), time_buffer));
1673 if (item->modify_date) 1679 if (item->modify_date)
1674 fprintf(f_output, "LAST-MOD:%s\n", pst_rfc2445_datetime_format(item->modify_date, sizeof(time_buffer), time_buffer)); 1680 fprintf(f_output, "LAST-MOD:%s\n", pst_rfc2445_datetime_format(item->modify_date, sizeof(time_buffer), time_buffer));
1675 if (item->subject.str) 1681 if (item->subject.str)
1676 fprintf(f_output, "SUMMARY:%s\n", pst_rfc2426_escape(item->subject.str)); 1682 fprintf(f_output, "SUMMARY:%s\n", pst_rfc2426_escape(item->subject.str, &result, &resultlen));
1677 if (item->body.str) 1683 if (item->body.str)
1678 fprintf(f_output, "DESCRIPTION:%s\n", pst_rfc2426_escape(item->body.str)); 1684 fprintf(f_output, "DESCRIPTION:%s\n", pst_rfc2426_escape(item->body.str, &result, &resultlen));
1679 if (journal && journal->start) 1685 if (journal && journal->start)
1680 fprintf(f_output, "DTSTART;VALUE=DATE-TIME:%s\n", pst_rfc2445_datetime_format(journal->start, sizeof(time_buffer), time_buffer)); 1686 fprintf(f_output, "DTSTART;VALUE=DATE-TIME:%s\n", pst_rfc2445_datetime_format(journal->start, sizeof(time_buffer), time_buffer));
1681 fprintf(f_output, "END:VJOURNAL\n"); 1687 fprintf(f_output, "END:VJOURNAL\n");
1688 if (result) free(result);
1682 } 1689 }
1683 1690
1684 1691
1685 void write_appointment(FILE* f_output, pst_item* item, int event_open) 1692 void write_appointment(FILE* f_output, pst_item* item, int event_open)
1686 { 1693 {
1687 char time_buffer[30]; 1694 char* result = NULL;
1695 size_t resultlen = 0;
1696 char time_buffer[30];
1688 pst_item_appointment* appointment = item->appointment; 1697 pst_item_appointment* appointment = item->appointment;
1689 1698
1690 // make everything utf8 1699 // make everything utf8
1691 pst_convert_utf8_null(item, &item->subject); 1700 pst_convert_utf8_null(item, &item->subject);
1692 pst_convert_utf8_null(item, &item->body); 1701 pst_convert_utf8_null(item, &item->body);
1697 if (item->create_date) 1706 if (item->create_date)
1698 fprintf(f_output, "CREATED:%s\n", pst_rfc2445_datetime_format(item->create_date, sizeof(time_buffer), time_buffer)); 1707 fprintf(f_output, "CREATED:%s\n", pst_rfc2445_datetime_format(item->create_date, sizeof(time_buffer), time_buffer));
1699 if (item->modify_date) 1708 if (item->modify_date)
1700 fprintf(f_output, "LAST-MOD:%s\n", pst_rfc2445_datetime_format(item->modify_date, sizeof(time_buffer), time_buffer)); 1709 fprintf(f_output, "LAST-MOD:%s\n", pst_rfc2445_datetime_format(item->modify_date, sizeof(time_buffer), time_buffer));
1701 if (item->subject.str) 1710 if (item->subject.str)
1702 fprintf(f_output, "SUMMARY:%s\n", pst_rfc2426_escape(item->subject.str)); 1711 fprintf(f_output, "SUMMARY:%s\n", pst_rfc2426_escape(item->subject.str, &result, &resultlen));
1703 if (item->body.str) 1712 if (item->body.str)
1704 fprintf(f_output, "DESCRIPTION:%s\n", pst_rfc2426_escape(item->body.str)); 1713 fprintf(f_output, "DESCRIPTION:%s\n", pst_rfc2426_escape(item->body.str, &result, &resultlen));
1705 if (appointment && appointment->start) 1714 if (appointment && appointment->start)
1706 fprintf(f_output, "DTSTART;VALUE=DATE-TIME:%s\n", pst_rfc2445_datetime_format(appointment->start, sizeof(time_buffer), time_buffer)); 1715 fprintf(f_output, "DTSTART;VALUE=DATE-TIME:%s\n", pst_rfc2445_datetime_format(appointment->start, sizeof(time_buffer), time_buffer));
1707 if (appointment && appointment->end) 1716 if (appointment && appointment->end)
1708 fprintf(f_output, "DTEND;VALUE=DATE-TIME:%s\n", pst_rfc2445_datetime_format(appointment->end, sizeof(time_buffer), time_buffer)); 1717 fprintf(f_output, "DTEND;VALUE=DATE-TIME:%s\n", pst_rfc2445_datetime_format(appointment->end, sizeof(time_buffer), time_buffer));
1709 if (appointment && appointment->location.str) 1718 if (appointment && appointment->location.str)
1710 fprintf(f_output, "LOCATION:%s\n", pst_rfc2426_escape(appointment->location.str)); 1719 fprintf(f_output, "LOCATION:%s\n", pst_rfc2426_escape(appointment->location.str, &result, &resultlen));
1711 if (appointment) { 1720 if (appointment) {
1712 switch (appointment->showas) { 1721 switch (appointment->showas) {
1713 case PST_FREEBUSY_TENTATIVE: 1722 case PST_FREEBUSY_TENTATIVE:
1714 fprintf(f_output, "STATUS:TENTATIVE\n"); 1723 fprintf(f_output, "STATUS:TENTATIVE\n");
1715 break; 1724 break;
1786 fprintf(f_output, "CATEGORIES:PHONE-CALL\n"); 1795 fprintf(f_output, "CATEGORIES:PHONE-CALL\n");
1787 break; 1796 break;
1788 } 1797 }
1789 } 1798 }
1790 fprintf(f_output, "END:VEVENT\n"); 1799 fprintf(f_output, "END:VEVENT\n");
1800 if (result) free(result);
1791 } 1801 }
1792 1802
1793 1803
1794 void create_enter_dir(struct file_ll* f, pst_item *item) 1804 void create_enter_dir(struct file_ll* f, pst_item *item)
1795 { 1805 {