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
00036
00037 #define PST_NO_ENCRYPT 0
00038 #define PST_COMP_ENCRYPT 1
00039 #define PST_ENCRYPT 2
00040
00041
00042 #define PST_MAP_ATTRIB (uint32_t)1
00043 #define PST_MAP_HEADER (uint32_t)2
00044
00045
00046 #define PST_ATTRIB_HEADER -1
00047
00048
00049 #define PST_FREEBUSY_FREE 0
00050 #define PST_FREEBUSY_TENTATIVE 1
00051 #define PST_FREEBUSY_BUSY 2
00052 #define PST_FREEBUSY_OUT_OF_OFFICE 3
00053
00054
00055 #define PST_APP_LABEL_NONE 0
00056 #define PST_APP_LABEL_IMPORTANT 1
00057 #define PST_APP_LABEL_BUSINESS 2
00058 #define PST_APP_LABEL_PERSONAL 3
00059 #define PST_APP_LABEL_VACATION 4
00060 #define PST_APP_LABEL_MUST_ATTEND 5
00061 #define PST_APP_LABEL_TRAVEL_REQ 6
00062 #define PST_APP_LABEL_NEEDS_PREP 7
00063 #define PST_APP_LABEL_BIRTHDAY 8
00064 #define PST_APP_LABEL_ANNIVERSARY 9
00065 #define PST_APP_LABEL_PHONE_CALL 10
00066
00067
00068 #define PST_APP_RECUR_NONE 0
00069 #define PST_APP_RECUR_DAILY 1
00070 #define PST_APP_RECUR_WEEKLY 2
00071 #define PST_APP_RECUR_MONTHLY 3
00072 #define PST_APP_RECUR_YEARLY 4
00073
00074
00075 #define PST_ATTACH_NONE 0
00076 #define PST_ATTACH_BY_VALUE 1
00077 #define PST_ATTACH_BY_REF 2
00078 #define PST_ATTACH_BY_REF_RESOLV 3
00079 #define PST_ATTACH_BY_REF_ONLY 4
00080 #define PST_ATTACH_EMBEDDED 5
00081 #define PST_ATTACH_OLE 6
00082
00083
00084 #define PST_FLAG_READ 0x01
00085 #define PST_FLAG_UNMODIFIED 0x02
00086 #define PST_FLAG_SUBMIT 0x04
00087 #define PST_FLAG_UNSENT 0x08
00088 #define PST_FLAG_HAS_ATTACHMENT 0x10
00089 #define PST_FLAG_FROM_ME 0x20
00090 #define PST_FLAG_ASSOCIATED 0x40
00091 #define PST_FLAG_RESEND 0x80
00092 #define PST_FLAG_RN_PENDING 0x100
00093 #define PST_FLAG_NRN_PENDING 0x200
00094
00095
00096 typedef struct pst_entryid {
00097 int32_t u1;
00098 char entryid[16];
00099 uint32_t id;
00100 } pst_entryid;
00101
00102
00103 typedef struct pst_index_ll {
00104 uint64_t i_id;
00105 uint64_t offset;
00106 uint64_t size;
00107 int64_t u1;
00108 } pst_index_ll;
00109
00110
00111 typedef struct pst_id2_tree {
00112 uint64_t id2;
00113 pst_index_ll *id;
00114 struct pst_id2_tree *child;
00115 struct pst_id2_tree *next;
00116 } pst_id2_tree;
00117
00118
00119 typedef struct pst_desc_tree {
00120 uint64_t d_id;
00121 uint64_t parent_d_id;
00122 pst_index_ll *desc;
00123 pst_index_ll *assoc_tree;
00124 int32_t no_child;
00125 struct pst_desc_tree *prev;
00126 struct pst_desc_tree *next;
00127 struct pst_desc_tree *parent;
00128 struct pst_desc_tree *child;
00129 struct pst_desc_tree *child_tail;
00130 } pst_desc_tree;
00131
00132
00137 typedef struct pst_string {
00140 int is_utf8;
00141 char *str;
00142 } pst_string;
00143
00144
00146 typedef struct pst_binary {
00147 size_t size;
00148 char *data;
00149 } pst_binary;
00150
00151
00154 typedef struct pst_item_email {
00156 FILETIME *arrival_date;
00161 int autoforward;
00163 pst_string cc_address;
00165 pst_string bcc_address;
00167 pst_binary conversation_index;
00171 int conversion_prohibited;
00175 int delete_after_submit;
00179 int delivery_report;
00181 pst_binary encrypted_body;
00183 pst_binary encrypted_htmlbody;
00185 pst_string header;
00187 pst_string htmlbody;
00192 int32_t importance;
00194 pst_string in_reply_to;
00198 int message_cc_me;
00202 int message_recip_me;
00206 int message_to_me;
00208 pst_string messageid;
00214 int32_t original_sensitivity;
00216 pst_string original_bcc;
00218 pst_string original_cc;
00220 pst_string original_to;
00222 pst_string outlook_recipient;
00224 pst_string outlook_recipient_name;
00226 pst_string outlook_recipient2;
00228 pst_string outlook_sender;
00230 pst_string outlook_sender_name;
00232 pst_string outlook_sender2;
00238 int32_t priority;
00240 pst_string processed_subject;
00244 int read_receipt;
00246 pst_string recip_access;
00248 pst_string recip_address;
00250 pst_string recip2_access;
00252 pst_string recip2_address;
00256 int reply_requested;
00258 pst_string reply_to;
00260 pst_string return_path_address;
00264 int32_t rtf_body_char_count;
00266 int32_t rtf_body_crc;
00270 pst_string rtf_body_tag;
00274 pst_binary rtf_compressed;
00282 int rtf_in_sync;
00285 int32_t rtf_ws_prefix_count;
00288 int32_t rtf_ws_trailing_count;
00290 pst_string sender_access;
00292 pst_string sender_address;
00294 pst_string sender2_access;
00296 pst_string sender2_address;
00302 int32_t sensitivity;
00304 FILETIME *sent_date;
00306 pst_entryid *sentmail_folder;
00308 pst_string sentto_address;
00310 pst_string report_text;
00312 FILETIME *report_time;
00314 int32_t ndr_reason_code;
00316 int32_t ndr_diag_code;
00318 pst_string supplementary_info;
00320 int32_t ndr_status_code;
00321
00322
00324 pst_string outlook_received_name1;
00326 pst_string outlook_sender_name2;
00328 pst_string outlook_normalized_subject;
00330 pst_string outlook_search_key;
00331 } pst_item_email;
00332
00333
00336 typedef struct pst_item_folder {
00338 int32_t item_count;
00340 int32_t unseen_item_count;
00344 int32_t assoc_count;
00349 int subfolder;
00350 } pst_item_folder;
00351
00352
00355 typedef struct pst_item_message_store {
00357 pst_entryid *top_of_personal_folder;
00359 pst_entryid *default_outbox_folder;
00361 pst_entryid *deleted_items_folder;
00363 pst_entryid *sent_items_folder;
00365 pst_entryid *user_views_folder;
00367 pst_entryid *common_view_folder;
00369 pst_entryid *search_root_folder;
00371 pst_entryid *top_of_folder;
00382 int32_t valid_mask;
00384 int32_t pwd_chksum;
00385 } pst_item_message_store;
00386
00387
00390 typedef struct pst_item_contact {
00392 pst_string account_name;
00394 pst_string address1;
00396 pst_string address1a;
00398 pst_string address1_desc;
00400 pst_string address1_transport;
00402 pst_string address2;
00404 pst_string address2a;
00406 pst_string address2_desc;
00408 pst_string address2_transport;
00410 pst_string address3;
00412 pst_string address3a;
00414 pst_string address3_desc;
00416 pst_string address3_transport;
00418 pst_string assistant_name;
00420 pst_string assistant_phone;
00422 pst_string billing_information;
00424 FILETIME *birthday;
00426 pst_string business_address;
00428 pst_string business_city;
00430 pst_string business_country;
00432 pst_string business_fax;
00434 pst_string business_homepage;
00436 pst_string business_phone;
00438 pst_string business_phone2;
00440 pst_string business_po_box;
00442 pst_string business_postal_code;
00444 pst_string business_state;
00446 pst_string business_street;
00448 pst_string callback_phone;
00450 pst_string car_phone;
00452 pst_string company_main_phone;
00454 pst_string company_name;
00456 pst_string computer_name;
00458 pst_string customer_id;
00460 pst_string def_postal_address;
00462 pst_string department;
00464 pst_string display_name_prefix;
00466 pst_string first_name;
00468 pst_string followup;
00470 pst_string free_busy_address;
00472 pst_string ftp_site;
00474 pst_string fullname;
00479 int16_t gender;
00481 pst_string gov_id;
00483 pst_string hobbies;
00485 pst_string home_address;
00487 pst_string home_city;
00489 pst_string home_country;
00491 pst_string home_fax;
00493 pst_string home_phone;
00495 pst_string home_phone2;
00497 pst_string home_po_box;
00499 pst_string home_postal_code;
00501 pst_string home_state;
00503 pst_string home_street;
00505 pst_string initials;
00507 pst_string isdn_phone;
00509 pst_string job_title;
00511 pst_string keyword;
00513 pst_string language;
00515 pst_string location;
00519 int mail_permission;
00521 pst_string manager_name;
00523 pst_string middle_name;
00525 pst_string mileage;
00527 pst_string mobile_phone;
00529 pst_string nickname;
00531 pst_string office_loc;
00533 pst_string common_name;
00535 pst_string org_id;
00537 pst_string other_address;
00539 pst_string other_city;
00541 pst_string other_country;
00543 pst_string other_phone;
00545 pst_string other_po_box;
00547 pst_string other_postal_code;
00549 pst_string other_state;
00551 pst_string other_street;
00553 pst_string pager_phone;
00555 pst_string personal_homepage;
00557 pst_string pref_name;
00559 pst_string primary_fax;
00561 pst_string primary_phone;
00563 pst_string profession;
00565 pst_string radio_phone;
00569 int rich_text;
00571 pst_string spouse_name;
00573 pst_string suffix;
00575 pst_string surname;
00577 pst_string telex;
00579 pst_string transmittable_display_name;
00581 pst_string ttytdd_phone;
00583 FILETIME *wedding_anniversary;
00585 pst_string work_address_street;
00587 pst_string work_address_city;
00589 pst_string work_address_state;
00591 pst_string work_address_postalcode;
00593 pst_string work_address_country;
00595 pst_string work_address_postofficebox;
00596 } pst_item_contact;
00597
00598
00601 typedef struct pst_item_attach {
00603 pst_string filename1;
00605 pst_string filename2;
00607 pst_string mimetype;
00609 pst_string content_id;
00611 pst_binary data;
00613 uint64_t id2_val;
00615 uint64_t i_id;
00617 pst_id2_tree *id2_head;
00626 int32_t method;
00628 int32_t position;
00630 int32_t sequence;
00631 struct pst_item_attach *next;
00632 } pst_item_attach;
00633
00634
00636 typedef struct pst_item_extra_field {
00637 char *field_name;
00638 char *value;
00639 struct pst_item_extra_field *next;
00640 } pst_item_extra_field;
00641
00642
00645 typedef struct pst_item_journal {
00647 FILETIME *start;
00649 FILETIME *end;
00651 pst_string type;
00653 pst_string description;
00654 } pst_item_journal;
00655
00656
00660 typedef struct pst_recurrence {
00662 uint32_t signature;
00667 uint32_t type;
00674 uint32_t sub_type;
00676 uint32_t parm1;
00677 uint32_t parm2;
00678 uint32_t parm3;
00679 uint32_t parm4;
00680 uint32_t parm5;
00686 uint32_t termination;
00688 uint32_t interval;
00690 uint32_t bydaymask;
00692 uint32_t dayofmonth;
00694 uint32_t monthofyear;
00696 uint32_t position;
00698 uint32_t count;
00699
00700
00701 } pst_recurrence;
00702
00703
00706 typedef struct pst_item_appointment {
00708 FILETIME *start;
00710 FILETIME *end;
00712 pst_string location;
00716 int alarm;
00718 FILETIME *reminder;
00720 int32_t alarm_minutes;
00722 pst_string alarm_filename;
00724 pst_string timezonestring;
00730 int32_t showas;
00743 int32_t label;
00747 int all_day;
00751 int is_recurring;
00758 int32_t recurrence_type;
00760 pst_string recurrence_description;
00762 pst_binary recurrence_data;
00764 FILETIME *recurrence_start;
00766 FILETIME *recurrence_end;
00767 } pst_item_appointment;
00768
00769
00773 typedef struct pst_item {
00775 struct pst_file *pf;
00777 uint64_t block_id;
00779 pst_item_email *email;
00781 pst_item_folder *folder;
00783 pst_item_contact *contact;
00785 pst_item_attach *attach;
00787 pst_item_message_store *message_store;
00789 pst_item_extra_field *extra_fields;
00791 pst_item_journal *journal;
00793 pst_item_appointment *appointment;
00804 int type;
00806 char *ascii_type;
00818 int32_t flags;
00820 pst_string file_as;
00822 pst_string comment;
00824 pst_string body_charset;
00826 pst_string body;
00828 pst_string subject;
00830 int32_t internet_cpid;
00832 int32_t message_codepage;
00834 int32_t message_size;
00836 pst_string outlook_version;
00838 pst_binary record_key;
00840 pst_binary predecessor_change;
00844 int response_requested;
00846 FILETIME *create_date;
00848 FILETIME *modify_date;
00852 int private_member;
00853 } pst_item;
00854
00855
00864 typedef struct pst_x_attrib_ll {
00868 uint32_t mytype;
00870 uint32_t map;
00872 void *data;
00874 struct pst_x_attrib_ll *next;
00875 } pst_x_attrib_ll;
00876
00877
00879 typedef struct pst_block_recorder {
00880 struct pst_block_recorder *next;
00881 int64_t offset;
00882 size_t size;
00883 int readcount;
00884 } pst_block_recorder;
00885
00886
00887 typedef struct pst_file {
00889 FILE* fp;
00891 char* cwd;
00893 char* fname;
00895 const char* charset;
00897 pst_index_ll *i_table;
00898 size_t i_count, i_capacity;
00900 pst_desc_tree *d_head, *d_tail;
00902 pst_x_attrib_ll *x_head;
00906 pst_block_recorder *block_head;
00907
00910 int do_read64;
00912 uint64_t index1;
00914 uint64_t index1_back;
00916 uint64_t index2;
00918 uint64_t index2_back;
00920 uint64_t size;
00924 unsigned char encryption;
00930 unsigned char ind_type;
00931 } pst_file;
00932
00933
00941 int pst_open(pst_file *pf, const char *name, const char *charset);
00942
00943
00948 int pst_reopen(pst_file *pf);
00949
00950
00956 int pst_load_index (pst_file *pf);
00957
00958
00963 int pst_load_extended_attributes(pst_file *pf);
00964
00965
00969 int pst_close(pst_file *pf);
00970
00971
00977 pst_desc_tree* pst_getTopOfFolders(pst_file *pf, const pst_item *root);
00978
00979
00986 pst_binary pst_attach_to_mem(pst_file *pf, pst_item_attach *attach);
00987
00988
00994 size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp);
00995
00996
01002 size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp);
01003
01004
01009 pst_desc_tree* pst_getNextDptr(pst_desc_tree* d);
01010
01011
01019 pst_item* pst_parse_item (pst_file *pf, pst_desc_tree *d_ptr, pst_id2_tree *m_head);
01020
01021
01025 void pst_freeItem(pst_item *item);
01026
01027
01033 pst_index_ll* pst_getID(pst_file* pf, uint64_t i_id);
01034
01035
01043 size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf);
01044
01045
01049 int pst_stricmp(char *a, char *b);
01050
01051
01059 size_t pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream);
01060
01061
01070 char* pst_rfc2426_escape(char* str, char** result, size_t* resultlen);
01071
01072
01080 char* pst_rfc2425_datetime_format(const FILETIME* ft, int buflen, char* result);
01081
01082
01089 char* pst_rfc2445_datetime_format(const FILETIME* ft, int buflen, char* result);
01090
01091
01097 char* pst_rfc2445_datetime_format_now(int buflen, char* result);
01098
01099
01107 const char* pst_default_charset(pst_item *item, int buflen, char* result);
01108
01109
01113 void pst_rfc2231(pst_string *str);
01114
01115
01121 void pst_rfc2047(pst_item *item, pst_string *str, int needs_quote);
01122
01123
01128 void pst_convert_utf8_null(pst_item *item, pst_string *str);
01129
01130
01135 void pst_convert_utf8(pst_item *item, pst_string *str);
01136
01137
01142 pst_recurrence* pst_convert_recurrence(pst_item_appointment* appt);
01143
01144
01148 void pst_free_recurrence(pst_recurrence* r);
01149
01150
01151
01152
01153
01154 #ifdef _MSC_VER
01155 #pragma pack(pop)
01156 #endif
01157 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
01158 #pragma pack()
01159 #endif
01160
01161
01162
01163 #endif