libpst.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __PST_LIBPST_H
00011 #define __PST_LIBPST_H
00012
00013 #include "common.h"
00014
00015
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019
00020
00021
00022
00023 #ifdef _MSC_VER
00024 #pragma pack(push, 1)
00025 #endif
00026 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
00027 #pragma pack(1)
00028 #endif
00029
00030
00031 #define PST_TYPE_NOTE 1
00032 #define PST_TYPE_SCHEDULE 2
00033 #define PST_TYPE_APPOINTMENT 8
00034 #define PST_TYPE_CONTACT 9
00035 #define PST_TYPE_JOURNAL 10
00036 #define PST_TYPE_STICKYNOTE 11
00037 #define PST_TYPE_TASK 12
00038 #define PST_TYPE_OTHER 13
00039 #define PST_TYPE_REPORT 14
00040 #define PST_TYPE_MAX 15
00041
00042
00043 #define PST_NO_ENCRYPT 0
00044 #define PST_COMP_ENCRYPT 1
00045 #define PST_ENCRYPT 2
00046
00047
00048 #define PST_MAP_ATTRIB (uint32_t)1
00049 #define PST_MAP_HEADER (uint32_t)2
00050
00051
00052 #define PST_ATTRIB_HEADER -1
00053
00054
00055 #define PST_FREEBUSY_FREE 0
00056 #define PST_FREEBUSY_TENTATIVE 1
00057 #define PST_FREEBUSY_BUSY 2
00058 #define PST_FREEBUSY_OUT_OF_OFFICE 3
00059
00060
00061 #define PST_APP_LABEL_NONE 0
00062 #define PST_APP_LABEL_IMPORTANT 1
00063 #define PST_APP_LABEL_BUSINESS 2
00064 #define PST_APP_LABEL_PERSONAL 3
00065 #define PST_APP_LABEL_VACATION 4
00066 #define PST_APP_LABEL_MUST_ATTEND 5
00067 #define PST_APP_LABEL_TRAVEL_REQ 6
00068 #define PST_APP_LABEL_NEEDS_PREP 7
00069 #define PST_APP_LABEL_BIRTHDAY 8
00070 #define PST_APP_LABEL_ANNIVERSARY 9
00071 #define PST_APP_LABEL_PHONE_CALL 10
00072
00073
00074 #define PST_APP_RECUR_NONE 0
00075 #define PST_APP_RECUR_DAILY 1
00076 #define PST_APP_RECUR_WEEKLY 2
00077 #define PST_APP_RECUR_MONTHLY 3
00078 #define PST_APP_RECUR_YEARLY 4
00079
00080
00081 #define PST_ATTACH_NONE 0
00082 #define PST_ATTACH_BY_VALUE 1
00083 #define PST_ATTACH_BY_REF 2
00084 #define PST_ATTACH_BY_REF_RESOLV 3
00085 #define PST_ATTACH_BY_REF_ONLY 4
00086 #define PST_ATTACH_EMBEDDED 5
00087 #define PST_ATTACH_OLE 6
00088
00089
00090 #define PST_FLAG_READ 0x01
00091 #define PST_FLAG_UNMODIFIED 0x02
00092 #define PST_FLAG_SUBMIT 0x04
00093 #define PST_FLAG_UNSENT 0x08
00094 #define PST_FLAG_HAS_ATTACHMENT 0x10
00095 #define PST_FLAG_FROM_ME 0x20
00096 #define PST_FLAG_ASSOCIATED 0x40
00097 #define PST_FLAG_RESEND 0x80
00098 #define PST_FLAG_RN_PENDING 0x100
00099 #define PST_FLAG_NRN_PENDING 0x200
00100
00101
00102 typedef struct pst_entryid {
00103 int32_t u1;
00104 char entryid[16];
00105 uint32_t id;
00106 } pst_entryid;
00107
00108
00109 typedef struct pst_index_ll {
00110 uint64_t i_id;
00111 uint64_t offset;
00112 uint64_t size;
00113 uint64_t inflated_size;
00114 int64_t u1;
00115 } pst_index_ll;
00116
00117
00118 typedef struct pst_id2_tree {
00119 uint64_t id2;
00120 pst_index_ll *id;
00121 struct pst_id2_tree *child;
00122 struct pst_id2_tree *next;
00123 } pst_id2_tree;
00124
00125
00126 typedef struct pst_desc_tree {
00127 uint64_t d_id;
00128 uint64_t parent_d_id;
00129 pst_index_ll *desc;
00130 pst_index_ll *assoc_tree;
00131 int32_t no_child;
00132 struct pst_desc_tree *prev;
00133 struct pst_desc_tree *next;
00134 struct pst_desc_tree *parent;
00135 struct pst_desc_tree *child;
00136 struct pst_desc_tree *child_tail;
00137 } pst_desc_tree;
00138
00139
00144 typedef struct pst_string {
00147 int is_utf8;
00148 char *str;
00149 } pst_string;
00150
00151
00153 typedef struct pst_binary {
00154 size_t size;
00155 char *data;
00156 } pst_binary;
00157
00158
00161 typedef struct pst_item_email {
00163 FILETIME *arrival_date;
00168 int autoforward;
00170 pst_string cc_address;
00172 pst_string bcc_address;
00174 pst_binary conversation_index;
00178 int conversion_prohibited;
00182 int delete_after_submit;
00186 int delivery_report;
00188 pst_binary encrypted_body;
00190 pst_binary encrypted_htmlbody;
00192 pst_string header;
00194 pst_string htmlbody;
00199 int32_t importance;
00201 pst_string in_reply_to;
00205 int message_cc_me;
00209 int message_recip_me;
00213 int message_to_me;
00215 pst_string messageid;
00221 int32_t original_sensitivity;
00223 pst_string original_bcc;
00225 pst_string original_cc;
00227 pst_string original_to;
00229 pst_string outlook_recipient;
00231 pst_string outlook_recipient_name;
00233 pst_string outlook_recipient2;
00235 pst_string outlook_sender;
00237 pst_string outlook_sender_name;
00239 pst_string outlook_sender2;
00245 int32_t priority;
00247 pst_string processed_subject;
00251 int read_receipt;
00253 pst_string recip_access;
00255 pst_string recip_address;
00257 pst_string recip2_access;
00259 pst_string recip2_address;
00263 int reply_requested;
00265 pst_string reply_to;
00267 pst_string return_path_address;
00271 int32_t rtf_body_char_count;
00273 int32_t rtf_body_crc;
00277 pst_string rtf_body_tag;
00281 pst_binary rtf_compressed;
00289 int rtf_in_sync;
00292 int32_t rtf_ws_prefix_count;
00295 int32_t rtf_ws_trailing_count;
00297 pst_string sender_access;
00299 pst_string sender_address;
00301 pst_string sender2_access;
00303 pst_string sender2_address;
00309 int32_t sensitivity;
00311 FILETIME *sent_date;
00313 pst_entryid *sentmail_folder;
00315 pst_string sentto_address;
00317 pst_string report_text;
00319 FILETIME *report_time;
00321 int32_t ndr_reason_code;
00323 int32_t ndr_diag_code;
00325 pst_string supplementary_info;
00327 int32_t ndr_status_code;
00328
00329
00331 pst_string outlook_received_name1;
00333 pst_string outlook_sender_name2;
00335 pst_string outlook_normalized_subject;
00337 pst_string outlook_search_key;
00338 } pst_item_email;
00339
00340
00343 typedef struct pst_item_folder {
00345 int32_t item_count;
00347 int32_t unseen_item_count;
00351 int32_t assoc_count;
00356 int subfolder;
00357 } pst_item_folder;
00358
00359
00362 typedef struct pst_item_message_store {
00364 pst_entryid *top_of_personal_folder;
00366 pst_entryid *default_outbox_folder;
00368 pst_entryid *deleted_items_folder;
00370 pst_entryid *sent_items_folder;
00372 pst_entryid *user_views_folder;
00374 pst_entryid *common_view_folder;
00376 pst_entryid *search_root_folder;
00378 pst_entryid *top_of_folder;
00389 int32_t valid_mask;
00391 int32_t pwd_chksum;
00392 } pst_item_message_store;
00393
00394
00397 typedef struct pst_item_contact {
00399 pst_string account_name;
00401 pst_string address1;
00403 pst_string address1a;
00405 pst_string address1_desc;
00407 pst_string address1_transport;
00409 pst_string address2;
00411 pst_string address2a;
00413 pst_string address2_desc;
00415 pst_string address2_transport;
00417 pst_string address3;
00419 pst_string address3a;
00421 pst_string address3_desc;
00423 pst_string address3_transport;
00425 pst_string assistant_name;
00427 pst_string assistant_phone;
00429 pst_string billing_information;
00431 FILETIME *birthday;
00433 pst_string business_address;
00435 pst_string business_city;
00437 pst_string business_country;
00439 pst_string business_fax;
00441 pst_string business_homepage;
00443 pst_string business_phone;
00445 pst_string business_phone2;
00447 pst_string business_po_box;
00449 pst_string business_postal_code;
00451 pst_string business_state;
00453 pst_string business_street;
00455 pst_string callback_phone;
00457 pst_string car_phone;
00459 pst_string company_main_phone;
00461 pst_string company_name;
00463 pst_string computer_name;
00465 pst_string customer_id;
00467 pst_string def_postal_address;
00469 pst_string department;
00471 pst_string display_name_prefix;
00473 pst_string first_name;
00475 pst_string followup;
00477 pst_string free_busy_address;
00479 pst_string ftp_site;
00481 pst_string fullname;
00486 int16_t gender;
00488 pst_string gov_id;
00490 pst_string hobbies;
00492 pst_string home_address;
00494 pst_string home_city;
00496 pst_string home_country;
00498 pst_string home_fax;
00500 pst_string home_phone;
00502 pst_string home_phone2;
00504 pst_string home_po_box;
00506 pst_string home_postal_code;
00508 pst_string home_state;
00510 pst_string home_street;
00512 pst_string initials;
00514 pst_string isdn_phone;
00516 pst_string job_title;
00518 pst_string keyword;
00520 pst_string language;
00522 pst_string location;
00526 int mail_permission;
00528 pst_string manager_name;
00530 pst_string middle_name;
00532 pst_string mileage;
00534 pst_string mobile_phone;
00536 pst_string nickname;
00538 pst_string office_loc;
00540 pst_string common_name;
00542 pst_string org_id;
00544 pst_string other_address;
00546 pst_string other_city;
00548 pst_string other_country;
00550 pst_string other_phone;
00552 pst_string other_po_box;
00554 pst_string other_postal_code;
00556 pst_string other_state;
00558 pst_string other_street;
00560 pst_string pager_phone;
00562 pst_string personal_homepage;
00564 pst_string pref_name;
00566 pst_string primary_fax;
00568 pst_string primary_phone;
00570 pst_string profession;
00572 pst_string radio_phone;
00576 int rich_text;
00578 pst_string spouse_name;
00580 pst_string suffix;
00582 pst_string surname;
00584 pst_string telex;
00586 pst_string transmittable_display_name;
00588 pst_string ttytdd_phone;
00590 FILETIME *wedding_anniversary;
00592 pst_string work_address_street;
00594 pst_string work_address_city;
00596 pst_string work_address_state;
00598 pst_string work_address_postalcode;
00600 pst_string work_address_country;
00602 pst_string work_address_postofficebox;
00603 } pst_item_contact;
00604
00605
00608 typedef struct pst_item_attach {
00610 pst_string filename1;
00612 pst_string filename2;
00614 pst_string mimetype;
00616 pst_string content_id;
00618 pst_binary data;
00620 uint64_t id2_val;
00622 uint64_t i_id;
00624 pst_id2_tree *id2_head;
00633 int32_t method;
00635 int32_t position;
00637 int32_t sequence;
00638 struct pst_item_attach *next;
00639 } pst_item_attach;
00640
00641
00643 typedef struct pst_item_extra_field {
00644 char *field_name;
00645 char *value;
00646 struct pst_item_extra_field *next;
00647 } pst_item_extra_field;
00648
00649
00652 typedef struct pst_item_journal {
00654 FILETIME *start;
00656 FILETIME *end;
00658 pst_string type;
00660 pst_string description;
00661 } pst_item_journal;
00662
00663
00667 typedef struct pst_recurrence {
00669 uint32_t signature;
00674 uint32_t type;
00681 uint32_t sub_type;
00683 uint32_t parm1;
00684 uint32_t parm2;
00685 uint32_t parm3;
00686 uint32_t parm4;
00687 uint32_t parm5;
00693 uint32_t termination;
00695 uint32_t interval;
00697 uint32_t bydaymask;
00699 uint32_t dayofmonth;
00701 uint32_t monthofyear;
00703 uint32_t position;
00705 uint32_t count;
00706
00707
00708 } pst_recurrence;
00709
00710
00713 typedef struct pst_item_appointment {
00715 FILETIME *start;
00717 FILETIME *end;
00719 pst_string location;
00723 int alarm;
00725 FILETIME *reminder;
00727 int32_t alarm_minutes;
00729 pst_string alarm_filename;
00731 pst_string timezonestring;
00737 int32_t showas;
00750 int32_t label;
00754 int all_day;
00758 int is_recurring;
00765 int32_t recurrence_type;
00767 pst_string recurrence_description;
00769 pst_binary recurrence_data;
00771 FILETIME *recurrence_start;
00773 FILETIME *recurrence_end;
00774 } pst_item_appointment;
00775
00776
00780 typedef struct pst_item {
00782 struct pst_file *pf;
00784 uint64_t block_id;
00786 pst_item_email *email;
00788 pst_item_folder *folder;
00790 pst_item_contact *contact;
00792 pst_item_attach *attach;
00794 pst_item_message_store *message_store;
00796 pst_item_extra_field *extra_fields;
00798 pst_item_journal *journal;
00800 pst_item_appointment *appointment;
00811 int type;
00813 char *ascii_type;
00825 int32_t flags;
00827 pst_string file_as;
00829 pst_string comment;
00831 pst_string body_charset;
00833 pst_string body;
00835 pst_string subject;
00837 int32_t internet_cpid;
00839 int32_t message_codepage;
00841 int32_t message_size;
00843 pst_string outlook_version;
00845 pst_binary record_key;
00847 pst_binary predecessor_change;
00851 int response_requested;
00853 FILETIME *create_date;
00855 FILETIME *modify_date;
00859 int private_member;
00860 } pst_item;
00861
00862
00871 typedef struct pst_x_attrib_ll {
00875 uint32_t mytype;
00877 uint32_t map;
00879 void *data;
00881 struct pst_x_attrib_ll *next;
00882 } pst_x_attrib_ll;
00883
00884
00886 typedef struct pst_block_recorder {
00887 struct pst_block_recorder *next;
00888 int64_t offset;
00889 size_t size;
00890 int readcount;
00891 } pst_block_recorder;
00892
00893
00894 typedef struct pst_file {
00896 FILE* fp;
00898 char* cwd;
00900 char* fname;
00902 const char* charset;
00904 pst_index_ll *i_table;
00905 size_t i_count, i_capacity;
00907 pst_desc_tree *d_head, *d_tail;
00909 pst_x_attrib_ll *x_head;
00913 pst_block_recorder *block_head;
00914
00918 int do_read64;
00920 uint64_t index1;
00922 uint64_t index1_back;
00924 uint64_t index2;
00926 uint64_t index2_back;
00928 uint64_t size;
00932 unsigned char encryption;
00938 unsigned char ind_type;
00939 } pst_file;
00940
00941
00949 int pst_open(pst_file *pf, const char *name, const char *charset);
00950
00951
00956 int pst_reopen(pst_file *pf);
00957
00958
00964 int pst_load_index (pst_file *pf);
00965
00966
00971 int pst_load_extended_attributes(pst_file *pf);
00972
00973
00977 int pst_close(pst_file *pf);
00978
00979
00985 pst_desc_tree* pst_getTopOfFolders(pst_file *pf, const pst_item *root);
00986
00987
00994 pst_binary pst_attach_to_mem(pst_file *pf, pst_item_attach *attach);
00995
00996
01002 size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp);
01003
01004
01010 size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp);
01011
01012
01017 pst_desc_tree* pst_getNextDptr(pst_desc_tree* d);
01018
01019
01027 pst_item* pst_parse_item (pst_file *pf, pst_desc_tree *d_ptr, pst_id2_tree *m_head);
01028
01029
01033 void pst_freeItem(pst_item *item);
01034
01035
01041 pst_index_ll* pst_getID(pst_file* pf, uint64_t i_id);
01042
01043
01051 size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf);
01052
01053
01057 int pst_stricmp(char *a, char *b);
01058
01059
01067 size_t pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream);
01068
01069
01078 char* pst_rfc2426_escape(char* str, char** result, size_t* resultlen);
01079
01080
01088 char* pst_rfc2425_datetime_format(const FILETIME* ft, int buflen, char* result);
01089
01090
01097 char* pst_rfc2445_datetime_format(const FILETIME* ft, int buflen, char* result);
01098
01099
01105 char* pst_rfc2445_datetime_format_now(int buflen, char* result);
01106
01107
01115 const char* pst_default_charset(pst_item *item, int buflen, char* result);
01116
01117
01121 void pst_rfc2231(pst_string *str);
01122
01123
01129 void pst_rfc2047(pst_item *item, pst_string *str, int needs_quote);
01130
01131
01136 void pst_convert_utf8_null(pst_item *item, pst_string *str);
01137
01138
01143 void pst_convert_utf8(pst_item *item, pst_string *str);
01144
01145
01150 pst_recurrence* pst_convert_recurrence(pst_item_appointment* appt);
01151
01152
01156 void pst_free_recurrence(pst_recurrence* r);
01157
01158
01159
01160
01161
01162 #ifdef _MSC_VER
01163 #pragma pack(pop)
01164 #endif
01165 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
01166 #pragma pack()
01167 #endif
01168
01169
01170
01171 #ifdef __cplusplus
01172 }
01173 #endif
01174
01175
01176
01177 #endif