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
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_SCHEDULE 2
00028 #define PST_TYPE_APPOINTMENT 8
00029 #define PST_TYPE_CONTACT 9
00030 #define PST_TYPE_JOURNAL 10
00031 #define PST_TYPE_STICKYNOTE 11
00032 #define PST_TYPE_TASK 12
00033 #define PST_TYPE_OTHER 13
00034 #define PST_TYPE_REPORT 14
00035 #define PST_TYPE_MAX 15
00036
00037
00038 #define PST_NO_ENCRYPT 0
00039 #define PST_COMP_ENCRYPT 1
00040 #define PST_ENCRYPT 2
00041
00042
00043 #define PST_MAP_ATTRIB (uint32_t)1
00044 #define PST_MAP_HEADER (uint32_t)2
00045
00046
00047 #define PST_ATTRIB_HEADER -1
00048
00049
00050 #define PST_FREEBUSY_FREE 0
00051 #define PST_FREEBUSY_TENTATIVE 1
00052 #define PST_FREEBUSY_BUSY 2
00053 #define PST_FREEBUSY_OUT_OF_OFFICE 3
00054
00055
00056 #define PST_APP_LABEL_NONE 0
00057 #define PST_APP_LABEL_IMPORTANT 1
00058 #define PST_APP_LABEL_BUSINESS 2
00059 #define PST_APP_LABEL_PERSONAL 3
00060 #define PST_APP_LABEL_VACATION 4
00061 #define PST_APP_LABEL_MUST_ATTEND 5
00062 #define PST_APP_LABEL_TRAVEL_REQ 6
00063 #define PST_APP_LABEL_NEEDS_PREP 7
00064 #define PST_APP_LABEL_BIRTHDAY 8
00065 #define PST_APP_LABEL_ANNIVERSARY 9
00066 #define PST_APP_LABEL_PHONE_CALL 10
00067
00068
00069 #define PST_APP_RECUR_NONE 0
00070 #define PST_APP_RECUR_DAILY 1
00071 #define PST_APP_RECUR_WEEKLY 2
00072 #define PST_APP_RECUR_MONTHLY 3
00073 #define PST_APP_RECUR_YEARLY 4
00074
00075
00076 #define PST_ATTACH_NONE 0
00077 #define PST_ATTACH_BY_VALUE 1
00078 #define PST_ATTACH_BY_REF 2
00079 #define PST_ATTACH_BY_REF_RESOLV 3
00080 #define PST_ATTACH_BY_REF_ONLY 4
00081 #define PST_ATTACH_EMBEDDED 5
00082 #define PST_ATTACH_OLE 6
00083
00084
00085 #define PST_FLAG_READ 0x01
00086 #define PST_FLAG_UNMODIFIED 0x02
00087 #define PST_FLAG_SUBMIT 0x04
00088 #define PST_FLAG_UNSENT 0x08
00089 #define PST_FLAG_HAS_ATTACHMENT 0x10
00090 #define PST_FLAG_FROM_ME 0x20
00091 #define PST_FLAG_ASSOCIATED 0x40
00092 #define PST_FLAG_RESEND 0x80
00093 #define PST_FLAG_RN_PENDING 0x100
00094 #define PST_FLAG_NRN_PENDING 0x200
00095
00096
00097 typedef struct pst_entryid {
00098 int32_t u1;
00099 char entryid[16];
00100 uint32_t id;
00101 } pst_entryid;
00102
00103
00104 typedef struct pst_index_ll {
00105 uint64_t i_id;
00106 uint64_t offset;
00107 uint64_t size;
00108 uint64_t inflated_size;
00109 int64_t u1;
00110 } pst_index_ll;
00111
00112
00113 typedef struct pst_id2_tree {
00114 uint64_t id2;
00115 pst_index_ll *id;
00116 struct pst_id2_tree *child;
00117 struct pst_id2_tree *next;
00118 } pst_id2_tree;
00119
00120
00121 typedef struct pst_desc_tree {
00122 uint64_t d_id;
00123 uint64_t parent_d_id;
00124 pst_index_ll *desc;
00125 pst_index_ll *assoc_tree;
00126 int32_t no_child;
00127 struct pst_desc_tree *prev;
00128 struct pst_desc_tree *next;
00129 struct pst_desc_tree *parent;
00130 struct pst_desc_tree *child;
00131 struct pst_desc_tree *child_tail;
00132 } pst_desc_tree;
00133
00134
00139 typedef struct pst_string {
00142 int is_utf8;
00143 char *str;
00144 } pst_string;
00145
00146
00148 typedef struct pst_binary {
00149 size_t size;
00150 char *data;
00151 } pst_binary;
00152
00153
00156 typedef struct pst_item_email {
00158 FILETIME *arrival_date;
00163 int autoforward;
00165 pst_string cc_address;
00167 pst_string bcc_address;
00169 pst_binary conversation_index;
00173 int conversion_prohibited;
00177 int delete_after_submit;
00181 int delivery_report;
00183 pst_binary encrypted_body;
00185 pst_binary encrypted_htmlbody;
00187 pst_string header;
00189 pst_string htmlbody;
00194 int32_t importance;
00196 pst_string in_reply_to;
00200 int message_cc_me;
00204 int message_recip_me;
00208 int message_to_me;
00210 pst_string messageid;
00216 int32_t original_sensitivity;
00218 pst_string original_bcc;
00220 pst_string original_cc;
00222 pst_string original_to;
00224 pst_string outlook_recipient;
00226 pst_string outlook_recipient_name;
00228 pst_string outlook_recipient2;
00230 pst_string outlook_sender;
00232 pst_string outlook_sender_name;
00234 pst_string outlook_sender2;
00240 int32_t priority;
00242 pst_string processed_subject;
00246 int read_receipt;
00248 pst_string recip_access;
00250 pst_string recip_address;
00252 pst_string recip2_access;
00254 pst_string recip2_address;
00258 int reply_requested;
00260 pst_string reply_to;
00262 pst_string return_path_address;
00266 int32_t rtf_body_char_count;
00268 int32_t rtf_body_crc;
00272 pst_string rtf_body_tag;
00276 pst_binary rtf_compressed;
00284 int rtf_in_sync;
00287 int32_t rtf_ws_prefix_count;
00290 int32_t rtf_ws_trailing_count;
00292 pst_string sender_access;
00294 pst_string sender_address;
00296 pst_string sender2_access;
00298 pst_string sender2_address;
00304 int32_t sensitivity;
00306 FILETIME *sent_date;
00308 pst_entryid *sentmail_folder;
00310 pst_string sentto_address;
00312 pst_string report_text;
00314 FILETIME *report_time;
00316 int32_t ndr_reason_code;
00318 int32_t ndr_diag_code;
00320 pst_string supplementary_info;
00322 int32_t ndr_status_code;
00323
00324
00326 pst_string outlook_received_name1;
00328 pst_string outlook_sender_name2;
00330 pst_string outlook_normalized_subject;
00332 pst_string outlook_search_key;
00333 } pst_item_email;
00334
00335
00338 typedef struct pst_item_folder {
00340 int32_t item_count;
00342 int32_t unseen_item_count;
00346 int32_t assoc_count;
00351 int subfolder;
00352 } pst_item_folder;
00353
00354
00357 typedef struct pst_item_message_store {
00359 pst_entryid *top_of_personal_folder;
00361 pst_entryid *default_outbox_folder;
00363 pst_entryid *deleted_items_folder;
00365 pst_entryid *sent_items_folder;
00367 pst_entryid *user_views_folder;
00369 pst_entryid *common_view_folder;
00371 pst_entryid *search_root_folder;
00373 pst_entryid *top_of_folder;
00384 int32_t valid_mask;
00386 int32_t pwd_chksum;
00387 } pst_item_message_store;
00388
00389
00392 typedef struct pst_item_contact {
00394 pst_string account_name;
00396 pst_string address1;
00398 pst_string address1a;
00400 pst_string address1_desc;
00402 pst_string address1_transport;
00404 pst_string address2;
00406 pst_string address2a;
00408 pst_string address2_desc;
00410 pst_string address2_transport;
00412 pst_string address3;
00414 pst_string address3a;
00416 pst_string address3_desc;
00418 pst_string address3_transport;
00420 pst_string assistant_name;
00422 pst_string assistant_phone;
00424 pst_string billing_information;
00426 FILETIME *birthday;
00428 pst_string business_address;
00430 pst_string business_city;
00432 pst_string business_country;
00434 pst_string business_fax;
00436 pst_string business_homepage;
00438 pst_string business_phone;
00440 pst_string business_phone2;
00442 pst_string business_po_box;
00444 pst_string business_postal_code;
00446 pst_string business_state;
00448 pst_string business_street;
00450 pst_string callback_phone;
00452 pst_string car_phone;
00454 pst_string company_main_phone;
00456 pst_string company_name;
00458 pst_string computer_name;
00460 pst_string customer_id;
00462 pst_string def_postal_address;
00464 pst_string department;
00466 pst_string display_name_prefix;
00468 pst_string first_name;
00470 pst_string followup;
00472 pst_string free_busy_address;
00474 pst_string ftp_site;
00476 pst_string fullname;
00481 int16_t gender;
00483 pst_string gov_id;
00485 pst_string hobbies;
00487 pst_string home_address;
00489 pst_string home_city;
00491 pst_string home_country;
00493 pst_string home_fax;
00495 pst_string home_phone;
00497 pst_string home_phone2;
00499 pst_string home_po_box;
00501 pst_string home_postal_code;
00503 pst_string home_state;
00505 pst_string home_street;
00507 pst_string initials;
00509 pst_string isdn_phone;
00511 pst_string job_title;
00513 pst_string keyword;
00515 pst_string language;
00517 pst_string location;
00521 int mail_permission;
00523 pst_string manager_name;
00525 pst_string middle_name;
00527 pst_string mileage;
00529 pst_string mobile_phone;
00531 pst_string nickname;
00533 pst_string office_loc;
00535 pst_string common_name;
00537 pst_string org_id;
00539 pst_string other_address;
00541 pst_string other_city;
00543 pst_string other_country;
00545 pst_string other_phone;
00547 pst_string other_po_box;
00549 pst_string other_postal_code;
00551 pst_string other_state;
00553 pst_string other_street;
00555 pst_string pager_phone;
00557 pst_string personal_homepage;
00559 pst_string pref_name;
00561 pst_string primary_fax;
00563 pst_string primary_phone;
00565 pst_string profession;
00567 pst_string radio_phone;
00571 int rich_text;
00573 pst_string spouse_name;
00575 pst_string suffix;
00577 pst_string surname;
00579 pst_string telex;
00581 pst_string transmittable_display_name;
00583 pst_string ttytdd_phone;
00585 FILETIME *wedding_anniversary;
00587 pst_string work_address_street;
00589 pst_string work_address_city;
00591 pst_string work_address_state;
00593 pst_string work_address_postalcode;
00595 pst_string work_address_country;
00597 pst_string work_address_postofficebox;
00598 } pst_item_contact;
00599
00600
00603 typedef struct pst_item_attach {
00605 pst_string filename1;
00607 pst_string filename2;
00609 pst_string mimetype;
00611 pst_string content_id;
00613 pst_binary data;
00615 uint64_t id2_val;
00617 uint64_t i_id;
00619 pst_id2_tree *id2_head;
00628 int32_t method;
00630 int32_t position;
00632 int32_t sequence;
00633 struct pst_item_attach *next;
00634 } pst_item_attach;
00635
00636
00638 typedef struct pst_item_extra_field {
00639 char *field_name;
00640 char *value;
00641 struct pst_item_extra_field *next;
00642 } pst_item_extra_field;
00643
00644
00647 typedef struct pst_item_journal {
00649 FILETIME *start;
00651 FILETIME *end;
00653 pst_string type;
00655 pst_string description;
00656 } pst_item_journal;
00657
00658
00662 typedef struct pst_recurrence {
00664 uint32_t signature;
00669 uint32_t type;
00676 uint32_t sub_type;
00678 uint32_t parm1;
00679 uint32_t parm2;
00680 uint32_t parm3;
00681 uint32_t parm4;
00682 uint32_t parm5;
00688 uint32_t termination;
00690 uint32_t interval;
00692 uint32_t bydaymask;
00694 uint32_t dayofmonth;
00696 uint32_t monthofyear;
00698 uint32_t position;
00700 uint32_t count;
00701
00702
00703 } pst_recurrence;
00704
00705
00708 typedef struct pst_item_appointment {
00710 FILETIME *start;
00712 FILETIME *end;
00714 pst_string location;
00718 int alarm;
00720 FILETIME *reminder;
00722 int32_t alarm_minutes;
00724 pst_string alarm_filename;
00726 pst_string timezonestring;
00732 int32_t showas;
00745 int32_t label;
00749 int all_day;
00753 int is_recurring;
00760 int32_t recurrence_type;
00762 pst_string recurrence_description;
00764 pst_binary recurrence_data;
00766 FILETIME *recurrence_start;
00768 FILETIME *recurrence_end;
00769 } pst_item_appointment;
00770
00771
00775 typedef struct pst_item {
00777 struct pst_file *pf;
00779 uint64_t block_id;
00781 pst_item_email *email;
00783 pst_item_folder *folder;
00785 pst_item_contact *contact;
00787 pst_item_attach *attach;
00789 pst_item_message_store *message_store;
00791 pst_item_extra_field *extra_fields;
00793 pst_item_journal *journal;
00795 pst_item_appointment *appointment;
00806 int type;
00808 char *ascii_type;
00820 int32_t flags;
00822 pst_string file_as;
00824 pst_string comment;
00826 pst_string body_charset;
00828 pst_string body;
00830 pst_string subject;
00832 int32_t internet_cpid;
00834 int32_t message_codepage;
00836 int32_t message_size;
00838 pst_string outlook_version;
00840 pst_binary record_key;
00842 pst_binary predecessor_change;
00846 int response_requested;
00848 FILETIME *create_date;
00850 FILETIME *modify_date;
00854 int private_member;
00855 } pst_item;
00856
00857
00866 typedef struct pst_x_attrib_ll {
00870 uint32_t mytype;
00872 uint32_t map;
00874 void *data;
00876 struct pst_x_attrib_ll *next;
00877 } pst_x_attrib_ll;
00878
00879
00881 typedef struct pst_block_recorder {
00882 struct pst_block_recorder *next;
00883 int64_t offset;
00884 size_t size;
00885 int readcount;
00886 } pst_block_recorder;
00887
00888
00889 typedef struct pst_file {
00891 FILE* fp;
00893 char* cwd;
00895 char* fname;
00897 const char* charset;
00899 pst_index_ll *i_table;
00900 size_t i_count, i_capacity;
00902 pst_desc_tree *d_head, *d_tail;
00904 pst_x_attrib_ll *x_head;
00908 pst_block_recorder *block_head;
00909
00913 int do_read64;
00915 uint64_t index1;
00917 uint64_t index1_back;
00919 uint64_t index2;
00921 uint64_t index2_back;
00923 uint64_t size;
00927 unsigned char encryption;
00933 unsigned char ind_type;
00934 } pst_file;
00935
00936
00944 int pst_open(pst_file *pf, const char *name, const char *charset);
00945
00946
00951 int pst_reopen(pst_file *pf);
00952
00953
00959 int pst_load_index (pst_file *pf);
00960
00961
00966 int pst_load_extended_attributes(pst_file *pf);
00967
00968
00972 int pst_close(pst_file *pf);
00973
00974
00980 pst_desc_tree* pst_getTopOfFolders(pst_file *pf, const pst_item *root);
00981
00982
00989 pst_binary pst_attach_to_mem(pst_file *pf, pst_item_attach *attach);
00990
00991
00997 size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp);
00998
00999
01005 size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp);
01006
01007
01012 pst_desc_tree* pst_getNextDptr(pst_desc_tree* d);
01013
01014
01022 pst_item* pst_parse_item (pst_file *pf, pst_desc_tree *d_ptr, pst_id2_tree *m_head);
01023
01024
01028 void pst_freeItem(pst_item *item);
01029
01030
01036 pst_index_ll* pst_getID(pst_file* pf, uint64_t i_id);
01037
01038
01046 size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf);
01047
01048
01052 int pst_stricmp(char *a, char *b);
01053
01054
01062 size_t pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream);
01063
01064
01073 char* pst_rfc2426_escape(char* str, char** result, size_t* resultlen);
01074
01075
01083 char* pst_rfc2425_datetime_format(const FILETIME* ft, int buflen, char* result);
01084
01085
01092 char* pst_rfc2445_datetime_format(const FILETIME* ft, int buflen, char* result);
01093
01094
01100 char* pst_rfc2445_datetime_format_now(int buflen, char* result);
01101
01102
01110 const char* pst_default_charset(pst_item *item, int buflen, char* result);
01111
01112
01116 void pst_rfc2231(pst_string *str);
01117
01118
01124 void pst_rfc2047(pst_item *item, pst_string *str, int needs_quote);
01125
01126
01131 void pst_convert_utf8_null(pst_item *item, pst_string *str);
01132
01133
01138 void pst_convert_utf8(pst_item *item, pst_string *str);
01139
01140
01145 pst_recurrence* pst_convert_recurrence(pst_item_appointment* appt);
01146
01147
01151 void pst_free_recurrence(pst_recurrence* r);
01152
01153
01154
01155
01156
01157 #ifdef _MSC_VER
01158 #pragma pack(pop)
01159 #endif
01160 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
01161 #pragma pack()
01162 #endif
01163
01164
01165
01166 #endif