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
00017
00018 #ifdef _MSC_VER
00019 #pragma pack(push, 1)
00020 #endif
00021 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
00022 #pragma pack(1)
00023 #endif
00024
00025
00026 #define PST_TYPE_NOTE 1
00027 #define PST_TYPE_APPOINTMENT 8
00028 #define PST_TYPE_CONTACT 9
00029 #define PST_TYPE_JOURNAL 10
00030 #define PST_TYPE_STICKYNOTE 11
00031 #define PST_TYPE_TASK 12
00032 #define PST_TYPE_OTHER 13
00033 #define PST_TYPE_REPORT 14
00034
00035
00036 #define PST_NO_ENCRYPT 0
00037 #define PST_COMP_ENCRYPT 1
00038 #define PST_ENCRYPT 2
00039
00040
00041 #define PST_MAP_ATTRIB (uint32_t)1
00042 #define PST_MAP_HEADER (uint32_t)2
00043
00044
00045 #define PST_ATTRIB_HEADER -1
00046
00047
00048 #define PST_FREEBUSY_FREE 0
00049 #define PST_FREEBUSY_TENTATIVE 1
00050 #define PST_FREEBUSY_BUSY 2
00051 #define PST_FREEBUSY_OUT_OF_OFFICE 3
00052
00053
00054 #define PST_APP_LABEL_NONE 0
00055 #define PST_APP_LABEL_IMPORTANT 1
00056 #define PST_APP_LABEL_BUSINESS 2
00057 #define PST_APP_LABEL_PERSONAL 3
00058 #define PST_APP_LABEL_VACATION 4
00059 #define PST_APP_LABEL_MUST_ATTEND 5
00060 #define PST_APP_LABEL_TRAVEL_REQ 6
00061 #define PST_APP_LABEL_NEEDS_PREP 7
00062 #define PST_APP_LABEL_BIRTHDAY 8
00063 #define PST_APP_LABEL_ANNIVERSARY 9
00064 #define PST_APP_LABEL_PHONE_CALL 10
00065
00066
00067 #define PST_APP_RECUR_NONE 0
00068 #define PST_APP_RECUR_DAILY 1
00069 #define PST_APP_RECUR_WEEKLY 2
00070 #define PST_APP_RECUR_MONTHLY 3
00071 #define PST_APP_RECUR_YEARLY 4
00072
00073
00074 typedef struct pst_entryid {
00075 int32_t u1;
00076 char entryid[16];
00077 uint32_t id;
00078 } pst_entryid;
00079
00080
00081 typedef struct pst_index_ll {
00082 uint64_t i_id;
00083 uint64_t offset;
00084 uint64_t size;
00085 int64_t u1;
00086 struct pst_index_ll *next;
00087 } pst_index_ll;
00088
00089
00090 typedef struct pst_id2_tree {
00091 uint64_t id2;
00092 pst_index_ll *id;
00093 struct pst_id2_tree *child;
00094 struct pst_id2_tree *next;
00095 } pst_id2_tree;
00096
00097
00098 typedef struct pst_desc_tree {
00099 uint64_t d_id;
00100 uint64_t parent_d_id;
00101 pst_index_ll *desc;
00102 pst_index_ll *assoc_tree;
00103 int32_t no_child;
00104 struct pst_desc_tree *prev;
00105 struct pst_desc_tree *next;
00106 struct pst_desc_tree *parent;
00107 struct pst_desc_tree *child;
00108 struct pst_desc_tree *child_tail;
00109 } pst_desc_tree;
00110
00111
00116 typedef struct pst_string {
00119 int is_utf8;
00120 char *str;
00121 } pst_string;
00122
00123
00125 typedef struct pst_binary {
00126 size_t size;
00127 char *data;
00128 } pst_binary;
00129
00130
00133 typedef struct pst_item_email {
00135 FILETIME *arrival_date;
00140 int autoforward;
00142 pst_string cc_address;
00144 pst_string bcc_address;
00146 pst_binary conversation_index;
00150 int conversion_prohibited;
00154 int delete_after_submit;
00158 int delivery_report;
00160 pst_binary encrypted_body;
00162 pst_binary encrypted_htmlbody;
00164 pst_string header;
00166 pst_string htmlbody;
00171 int32_t importance;
00173 pst_string in_reply_to;
00177 int message_cc_me;
00181 int message_recip_me;
00185 int message_to_me;
00187 pst_string messageid;
00193 int32_t original_sensitivity;
00195 pst_string original_bcc;
00197 pst_string original_cc;
00199 pst_string original_to;
00201 pst_string outlook_recipient;
00203 pst_string outlook_recipient_name;
00205 pst_string outlook_recipient2;
00207 pst_string outlook_sender;
00209 pst_string outlook_sender_name;
00211 pst_string outlook_sender2;
00217 int32_t priority;
00219 pst_string processed_subject;
00223 int read_receipt;
00225 pst_string recip_access;
00227 pst_string recip_address;
00229 pst_string recip2_access;
00231 pst_string recip2_address;
00235 int reply_requested;
00237 pst_string reply_to;
00239 pst_string return_path_address;
00243 int32_t rtf_body_char_count;
00245 int32_t rtf_body_crc;
00249 pst_string rtf_body_tag;
00253 pst_binary rtf_compressed;
00261 int rtf_in_sync;
00264 int32_t rtf_ws_prefix_count;
00267 int32_t rtf_ws_trailing_count;
00269 pst_string sender_access;
00271 pst_string sender_address;
00273 pst_string sender2_access;
00275 pst_string sender2_address;
00281 int32_t sensitivity;
00283 FILETIME *sent_date;
00285 pst_entryid *sentmail_folder;
00287 pst_string sentto_address;
00289 pst_string report_text;
00291 FILETIME *report_time;
00293 int32_t ndr_reason_code;
00295 int32_t ndr_diag_code;
00297 pst_string supplementary_info;
00299 int32_t ndr_status_code;
00300 } pst_item_email;
00301
00302
00305 typedef struct pst_item_folder {
00307 int32_t item_count;
00309 int32_t unseen_item_count;
00313 int32_t assoc_count;
00318 int subfolder;
00319 } pst_item_folder;
00320
00321
00324 typedef struct pst_item_message_store {
00326 pst_entryid *top_of_personal_folder;
00328 pst_entryid *default_outbox_folder;
00330 pst_entryid *deleted_items_folder;
00332 pst_entryid *sent_items_folder;
00334 pst_entryid *user_views_folder;
00336 pst_entryid *common_view_folder;
00338 pst_entryid *search_root_folder;
00340 pst_entryid *top_of_folder;
00351 int32_t valid_mask;
00353 int32_t pwd_chksum;
00354 } pst_item_message_store;
00355
00356
00359 typedef struct pst_item_contact {
00361 pst_string access_method;
00363 pst_string account_name;
00365 pst_string address1;
00367 pst_string address1a;
00369 pst_string address1_desc;
00371 pst_string address1_transport;
00373 pst_string address2;
00375 pst_string address2a;
00377 pst_string address2_desc;
00379 pst_string address2_transport;
00381 pst_string address3;
00383 pst_string address3a;
00385 pst_string address3_desc;
00387 pst_string address3_transport;
00389 pst_string assistant_name;
00391 pst_string assistant_phone;
00393 pst_string billing_information;
00395 FILETIME *birthday;
00397 pst_string business_address;
00399 pst_string business_city;
00401 pst_string business_country;
00403 pst_string business_fax;
00405 pst_string business_homepage;
00407 pst_string business_phone;
00409 pst_string business_phone2;
00411 pst_string business_po_box;
00413 pst_string business_postal_code;
00415 pst_string business_state;
00417 pst_string business_street;
00419 pst_string callback_phone;
00421 pst_string car_phone;
00423 pst_string company_main_phone;
00425 pst_string company_name;
00427 pst_string computer_name;
00429 pst_string customer_id;
00431 pst_string def_postal_address;
00433 pst_string department;
00435 pst_string display_name_prefix;
00437 pst_string first_name;
00439 pst_string followup;
00441 pst_string free_busy_address;
00443 pst_string ftp_site;
00445 pst_string fullname;
00450 int16_t gender;
00452 pst_string gov_id;
00454 pst_string hobbies;
00456 pst_string home_address;
00458 pst_string home_city;
00460 pst_string home_country;
00462 pst_string home_fax;
00464 pst_string home_phone;
00466 pst_string home_phone2;
00468 pst_string home_po_box;
00470 pst_string home_postal_code;
00472 pst_string home_state;
00474 pst_string home_street;
00476 pst_string initials;
00478 pst_string isdn_phone;
00480 pst_string job_title;
00482 pst_string keyword;
00484 pst_string language;
00486 pst_string location;
00490 int mail_permission;
00492 pst_string manager_name;
00494 pst_string middle_name;
00496 pst_string mileage;
00498 pst_string mobile_phone;
00500 pst_string nickname;
00502 pst_string office_loc;
00504 pst_string common_name;
00506 pst_string org_id;
00508 pst_string other_address;
00510 pst_string other_city;
00512 pst_string other_country;
00514 pst_string other_phone;
00516 pst_string other_po_box;
00518 pst_string other_postal_code;
00520 pst_string other_state;
00522 pst_string other_street;
00524 pst_string pager_phone;
00526 pst_string personal_homepage;
00528 pst_string pref_name;
00530 pst_string primary_fax;
00532 pst_string primary_phone;
00534 pst_string profession;
00536 pst_string radio_phone;
00540 int rich_text;
00542 pst_string spouse_name;
00544 pst_string suffix;
00546 pst_string surname;
00548 pst_string telex;
00550 pst_string transmittable_display_name;
00552 pst_string ttytdd_phone;
00554 FILETIME *wedding_anniversary;
00556 pst_string work_address_street;
00558 pst_string work_address_city;
00560 pst_string work_address_state;
00562 pst_string work_address_postalcode;
00564 pst_string work_address_country;
00566 pst_string work_address_postofficebox;
00567 } pst_item_contact;
00568
00569
00572 typedef struct pst_item_attach {
00574 pst_string filename1;
00576 pst_string filename2;
00578 pst_string mimetype;
00580 pst_binary data;
00582 uint64_t id2_val;
00584 uint64_t i_id;
00586 pst_id2_tree *id2_head;
00595 int32_t method;
00597 int32_t position;
00599 int32_t sequence;
00600 struct pst_item_attach *next;
00601 } pst_item_attach;
00602
00603
00605 typedef struct pst_item_extra_field {
00606 char *field_name;
00607 char *value;
00608 struct pst_item_extra_field *next;
00609 } pst_item_extra_field;
00610
00611
00614 typedef struct pst_item_journal {
00616 FILETIME *end;
00618 FILETIME *start;
00620 pst_string type;
00622 pst_string description;
00623 } pst_item_journal;
00624
00625
00628 typedef struct pst_item_appointment {
00630 FILETIME *end;
00632 pst_string location;
00636 int alarm;
00638 FILETIME *reminder;
00640 int32_t alarm_minutes;
00642 pst_string alarm_filename;
00644 FILETIME *start;
00646 pst_string timezonestring;
00652 int32_t showas;
00665 int32_t label;
00669 int all_day;
00671 pst_string recurrence;
00678 int32_t recurrence_type;
00680 FILETIME *recurrence_start;
00682 FILETIME *recurrence_end;
00683 } pst_item_appointment;
00684
00685
00689 typedef struct pst_item {
00691 pst_item_email *email;
00693 pst_item_folder *folder;
00695 pst_item_contact *contact;
00697 pst_item_attach *attach;
00699 pst_item_message_store *message_store;
00701 pst_item_extra_field *extra_fields;
00703 pst_item_journal *journal;
00705 pst_item_appointment *appointment;
00715 int type;
00717 char *ascii_type;
00729 int32_t flags;
00731 pst_string file_as;
00733 pst_string comment;
00735 pst_string body_charset;
00737 pst_string body;
00739 pst_string subject;
00741 int32_t internet_cpid;
00743 int32_t message_codepage;
00745 int32_t message_size;
00747 pst_string outlook_version;
00749 pst_binary record_key;
00751 pst_binary predecessor_change;
00755 int response_requested;
00757 FILETIME *create_date;
00759 FILETIME *modify_date;
00763 int private_member;
00764 } pst_item;
00765
00766
00775 typedef struct pst_x_attrib_ll {
00777 uint32_t type;
00781 uint32_t mytype;
00783 uint32_t map;
00785 void *data;
00787 struct pst_x_attrib_ll *next;
00788 } pst_x_attrib_ll;
00789
00790
00792 typedef struct pst_block_recorder {
00793 struct pst_block_recorder *next;
00794 int64_t offset;
00795 size_t size;
00796 int readcount;
00797 } pst_block_recorder;
00798
00799
00800 typedef struct pst_file {
00802 pst_index_ll *i_head, *i_tail;
00804 pst_desc_tree *d_head, *d_tail;
00806 pst_x_attrib_ll *x_head;
00810 pst_block_recorder *block_head;
00811
00814 int do_read64;
00816 uint64_t index1;
00818 uint64_t index1_back;
00820 uint64_t index2;
00822 uint64_t index2_back;
00824 FILE * fp;
00826 uint64_t size;
00830 unsigned char encryption;
00836 unsigned char ind_type;
00837 } pst_file;
00838
00839
00846 int pst_open(pst_file *pf, char *name);
00847
00848
00854 int pst_load_index (pst_file *pf);
00855
00856
00861 int pst_load_extended_attributes(pst_file *pf);
00862
00863
00867 int pst_close(pst_file *pf);
00868
00869
00875 pst_desc_tree* pst_getTopOfFolders(pst_file *pf, pst_item *root);
00876
00877
00885 size_t pst_attach_to_mem(pst_file *pf, pst_item_attach *attach, char **b);
00886
00887
00893 size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp);
00894
00895
00901 size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp);
00902
00903
00908 pst_desc_tree* pst_getNextDptr(pst_desc_tree* d);
00909
00910
00918 pst_item* pst_parse_item (pst_file *pf, pst_desc_tree *d_ptr, pst_id2_tree *m_head);
00919
00920
00924 void pst_freeItem(pst_item *item);
00925
00926
00932 pst_index_ll* pst_getID(pst_file* pf, uint64_t i_id);
00933
00934
00945 int pst_decrypt(uint64_t i_id, char *buf, size_t size, unsigned char type);
00946
00947
00955 size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf);
00956
00957
00965 size_t pst_ff_getIDblock(pst_file *pf, uint64_t i_id, char** buf);
00966
00967
00975 size_t pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream);
00976
00977
00985 char * pst_rfc2426_escape(char *str);
00986
00987
00993 char * pst_rfc2425_datetime_format(FILETIME *ft);
00994
00995
01000 char * pst_rfc2445_datetime_format(FILETIME *ft);
01001
01002
01008 const char* pst_default_charset(pst_item *item);
01009
01010
01015 void pst_convert_utf8_null(pst_item *item, pst_string *str);
01016
01017
01022 void pst_convert_utf8(pst_item *item, pst_string *str);
01023
01024
01025
01026
01027 #ifdef _MSC_VER
01028 #pragma pack(pop)
01029 #endif
01030 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
01031 #pragma pack()
01032 #endif
01033
01034
01035
01036 #endif