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 // None
00055 #define PST_APP_LABEL_IMPORTANT 1 // Important
00056 #define PST_APP_LABEL_BUSINESS 2 // Business
00057 #define PST_APP_LABEL_PERSONAL 3 // Personal
00058 #define PST_APP_LABEL_VACATION 4 // Vacation
00059 #define PST_APP_LABEL_MUST_ATTEND 5 // Must Attend
00060 #define PST_APP_LABEL_TRAVEL_REQ 6 // Travel Required
00061 #define PST_APP_LABEL_NEEDS_PREP 7 // Needs Preparation
00062 #define PST_APP_LABEL_BIRTHDAY 8 // Birthday
00063 #define PST_APP_LABEL_ANNIVERSARY 9 // Anniversary
00064 #define PST_APP_LABEL_PHONE_CALL 10// Phone Call
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_misc_6 {
00075 int32_t i1;
00076 int32_t i2;
00077 int32_t i3;
00078 int32_t i4;
00079 int32_t i5;
00080 int32_t i6;
00081 } pst_misc_6;
00082
00083
00084 typedef struct pst_entryid {
00085 int32_t u1;
00086 char entryid[16];
00087 uint32_t id;
00088 } pst_entryid;
00089
00090
00091 typedef struct pst_desc32 {
00092 uint32_t d_id;
00093 uint32_t desc_id;
00094 uint32_t tree_id;
00095 uint32_t parent_d_id;
00096 } pst_desc32;
00097
00098
00099 typedef struct pst_desc {
00100 uint64_t d_id;
00101 uint64_t desc_id;
00102 uint64_t tree_id;
00103 uint32_t parent_d_id;
00104 uint32_t u1;
00105 } pst_desc;
00106
00107
00108 typedef struct pst_index32 {
00109 uint32_t id;
00110 uint32_t offset;
00111 uint16_t size;
00112 int16_t u1;
00113 } pst_index32;
00114
00115
00116 typedef struct pst_index {
00117 uint64_t id;
00118 uint64_t offset;
00119 uint16_t size;
00120 int16_t u0;
00121 int32_t u1;
00122 } pst_index;
00123
00124
00125 typedef struct pst_index_ll {
00126 uint64_t i_id;
00127 uint64_t offset;
00128 uint64_t size;
00129 int64_t u1;
00130 struct pst_index_ll *next;
00131 } pst_index_ll;
00132
00133
00134 typedef struct pst_id2_tree {
00135 uint64_t id2;
00136 pst_index_ll *id;
00137 struct pst_id2_tree *child;
00138 struct pst_id2_tree *next;
00139 } pst_id2_tree;
00140
00141
00142 typedef struct pst_desc_tree {
00143 uint64_t d_id;
00144 uint64_t parent_d_id;
00145 pst_index_ll *desc;
00146 pst_index_ll *assoc_tree;
00147 int32_t no_child;
00148 struct pst_desc_tree *prev;
00149 struct pst_desc_tree *next;
00150 struct pst_desc_tree *parent;
00151 struct pst_desc_tree *child;
00152 struct pst_desc_tree *child_tail;
00153 } pst_desc_tree;
00154
00155
00156 typedef struct pst_string {
00157 int is_utf8;
00158 char *str;
00159 } pst_string;
00160
00161
00162 typedef struct pst_binary {
00163 size_t size;
00164 char *data;
00165 } pst_binary;
00166
00167
00170 typedef struct pst_item_email {
00171 FILETIME *arrival_date;
00173 int autoforward;
00174 pst_string cc_address;
00175 pst_string bcc_address;
00176 pst_binary conversation_index;
00178 int conversion_prohibited;
00180 int delete_after_submit;
00182 int delivery_report;
00183 pst_binary encrypted_body;
00184 pst_binary encrypted_htmlbody;
00185 pst_string header;
00186 pst_string htmlbody;
00188 int32_t importance;
00189 pst_string in_reply_to;
00191 int message_cc_me;
00193 int message_recip_me;
00195 int message_to_me;
00196 pst_string messageid;
00198 int32_t original_sensitivity;
00199 pst_string original_bcc;
00200 pst_string original_cc;
00201 pst_string original_to;
00202 pst_string outlook_recipient;
00203 pst_string outlook_recipient_name;
00204 pst_string outlook_recipient2;
00205 pst_string outlook_sender;
00206 pst_string outlook_sender_name;
00207 pst_string outlook_sender2;
00209 int32_t priority;
00210 pst_string processed_subject;
00212 int read_receipt;
00213 pst_string recip_access;
00214 pst_string recip_address;
00215 pst_string recip2_access;
00216 pst_string recip2_address;
00218 int reply_requested;
00219 pst_string reply_to;
00220 pst_string return_path_address;
00221 int32_t rtf_body_char_count;
00222 int32_t rtf_body_crc;
00223 pst_string rtf_body_tag;
00224 pst_binary rtf_compressed;
00226 int rtf_in_sync;
00227 int32_t rtf_ws_prefix_count;
00228 int32_t rtf_ws_trailing_count;
00229 pst_string sender_access;
00230 pst_string sender_address;
00231 pst_string sender2_access;
00232 pst_string sender2_address;
00234 int32_t sensitivity;
00235 FILETIME *sent_date;
00236 pst_entryid *sentmail_folder;
00237 pst_string sentto_address;
00238
00239 pst_string report_text;
00240 FILETIME *report_time;
00241 int32_t ndr_reason_code;
00242 int32_t ndr_diag_code;
00243 pst_string supplementary_info;
00244 int32_t ndr_status_code;
00245 } pst_item_email;
00246
00247
00248 typedef struct pst_item_folder {
00249 int32_t item_count;
00250 int32_t unseen_item_count;
00251 int32_t assoc_count;
00253 int subfolder;
00254 } pst_item_folder;
00255
00256
00257 typedef struct pst_item_message_store {
00258 pst_entryid *top_of_personal_folder;
00259 pst_entryid *default_outbox_folder;
00260 pst_entryid *deleted_items_folder;
00261 pst_entryid *sent_items_folder;
00262 pst_entryid *user_views_folder;
00263 pst_entryid *common_view_folder;
00264 pst_entryid *search_root_folder;
00265 pst_entryid *top_of_folder;
00276 int32_t valid_mask;
00277 int32_t pwd_chksum;
00278 } pst_item_message_store;
00279
00280
00283 typedef struct pst_item_contact {
00284 pst_string access_method;
00285 pst_string account_name;
00286 pst_string address1;
00287 pst_string address1a;
00288 pst_string address1_desc;
00289 pst_string address1_transport;
00290 pst_string address2;
00291 pst_string address2a;
00292 pst_string address2_desc;
00293 pst_string address2_transport;
00294 pst_string address3;
00295 pst_string address3a;
00296 pst_string address3_desc;
00297 pst_string address3_transport;
00298 pst_string assistant_name;
00299 pst_string assistant_phone;
00300 pst_string billing_information;
00301 FILETIME *birthday;
00302 pst_string business_address;
00303 pst_string business_city;
00304 pst_string business_country;
00305 pst_string business_fax;
00306 pst_string business_homepage;
00307 pst_string business_phone;
00308 pst_string business_phone2;
00309 pst_string business_po_box;
00310 pst_string business_postal_code;
00311 pst_string business_state;
00312 pst_string business_street;
00313 pst_string callback_phone;
00314 pst_string car_phone;
00315 pst_string company_main_phone;
00316 pst_string company_name;
00317 pst_string computer_name;
00318 pst_string customer_id;
00319 pst_string def_postal_address;
00320 pst_string department;
00321 pst_string display_name_prefix;
00322 pst_string first_name;
00323 pst_string followup;
00324 pst_string free_busy_address;
00325 pst_string ftp_site;
00326 pst_string fullname;
00328 int16_t gender;
00329 pst_string gov_id;
00330 pst_string hobbies;
00331 pst_string home_address;
00332 pst_string home_city;
00333 pst_string home_country;
00334 pst_string home_fax;
00335 pst_string home_phone;
00336 pst_string home_phone2;
00337 pst_string home_po_box;
00338 pst_string home_postal_code;
00339 pst_string home_state;
00340 pst_string home_street;
00341 pst_string initials;
00342 pst_string isdn_phone;
00343 pst_string job_title;
00344 pst_string keyword;
00345 pst_string language;
00346 pst_string location;
00348 int mail_permission;
00349 pst_string manager_name;
00350 pst_string middle_name;
00351 pst_string mileage;
00352 pst_string mobile_phone;
00353 pst_string nickname;
00354 pst_string office_loc;
00355 pst_string common_name;
00356 pst_string org_id;
00357 pst_string other_address;
00358 pst_string other_city;
00359 pst_string other_country;
00360 pst_string other_phone;
00361 pst_string other_po_box;
00362 pst_string other_postal_code;
00363 pst_string other_state;
00364 pst_string other_street;
00365 pst_string pager_phone;
00366 pst_string personal_homepage;
00367 pst_string pref_name;
00368 pst_string primary_fax;
00369 pst_string primary_phone;
00370 pst_string profession;
00371 pst_string radio_phone;
00373 int rich_text;
00374 pst_string spouse_name;
00375 pst_string suffix;
00376 pst_string surname;
00377 pst_string telex;
00378 pst_string transmittable_display_name;
00379 pst_string ttytdd_phone;
00380 FILETIME *wedding_anniversary;
00381 pst_string work_address_street;
00382 pst_string work_address_city;
00383 pst_string work_address_state;
00384 pst_string work_address_postalcode;
00385 pst_string work_address_country;
00386 pst_string work_address_postofficebox;
00387 } pst_item_contact;
00388
00389
00390 typedef struct pst_item_attach {
00391 pst_string filename1;
00392 pst_string filename2;
00393 pst_string mimetype;
00394 pst_binary data;
00395 uint64_t id2_val;
00397 uint64_t i_id;
00399 pst_id2_tree *id2_head;
00401 int32_t method;
00402 int32_t position;
00403 int32_t sequence;
00404 struct pst_item_attach *next;
00405 } pst_item_attach;
00406
00407
00408 typedef struct pst_item_extra_field {
00409 char *field_name;
00410 char *value;
00411 struct pst_item_extra_field *next;
00412 } pst_item_extra_field;
00413
00414
00417 typedef struct pst_item_journal {
00418 FILETIME *end;
00419 FILETIME *start;
00420 pst_string type;
00421 pst_string description;
00422 } pst_item_journal;
00423
00424
00427 typedef struct pst_item_appointment {
00428 FILETIME *end;
00429 pst_string location;
00431 int alarm;
00432 FILETIME *reminder;
00433 int32_t alarm_minutes;
00434 pst_string alarm_filename;
00435 FILETIME *start;
00436 pst_string timezonestring;
00438 int32_t showas;
00451 int32_t label;
00453 int all_day;
00455 pst_string recurrence;
00457 int32_t recurrence_type;
00458 FILETIME *recurrence_start;
00459 FILETIME *recurrence_end;
00460 } pst_item_appointment;
00461
00462
00463 typedef struct pst_item {
00464 pst_item_email *email;
00465 pst_item_folder *folder;
00466 pst_item_contact *contact;
00467 pst_item_attach *attach;
00468 pst_item_message_store *message_store;
00469 pst_item_extra_field *extra_fields;
00470 pst_item_journal *journal;
00471 pst_item_appointment *appointment;
00472 int type;
00473 char *ascii_type;
00485 int32_t flags;
00486 pst_string file_as;
00487 pst_string comment;
00489 pst_string body_charset;
00491 pst_string body;
00493 pst_string subject;
00494 int32_t internet_cpid;
00495 int32_t message_codepage;
00496 int32_t message_size;
00497 pst_string outlook_version;
00498 pst_binary record_key;
00499 pst_binary predecessor_change;
00501 int response_requested;
00502 FILETIME *create_date;
00503 FILETIME *modify_date;
00505 int private_member;
00506 } pst_item;
00507
00508
00509 typedef struct pst_x_attrib_ll {
00510 uint32_t type;
00511 uint32_t mytype;
00512 uint32_t map;
00513 void *data;
00514 struct pst_x_attrib_ll *next;
00515 } pst_x_attrib_ll;
00516
00517
00518 typedef struct pst_block_recorder {
00519 struct pst_block_recorder *next;
00520 int64_t offset;
00521 size_t size;
00522 int readcount;
00523 } pst_block_recorder;
00524
00525
00526 typedef struct pst_file {
00527 pst_index_ll *i_head, *i_tail;
00528 pst_desc_tree *d_head, *d_tail;
00529 pst_x_attrib_ll *x_head;
00530 pst_block_recorder *block_head;
00531
00535 int do_read64;
00536 uint64_t index1;
00537 uint64_t index1_back;
00538 uint64_t index2;
00539 uint64_t index2_back;
00540 FILE * fp;
00541 uint64_t size;
00542 unsigned char encryption;
00543 unsigned char ind_type;
00544 } pst_file;
00545
00546
00547 typedef struct pst_block_offset {
00548 int16_t from;
00549 int16_t to;
00550 } pst_block_offset;
00551
00552
00553 typedef struct pst_block_offset_pointer {
00554 char *from;
00555 char *to;
00556 int needfree;
00557 } pst_block_offset_pointer;
00558
00559
00560 typedef struct pst_mapi_element {
00561 uint32_t mapi_id;
00562 char *data;
00563 uint32_t type;
00564 size_t size;
00565 char *extra;
00566 } pst_mapi_element;
00567
00568
00569 typedef struct pst_mapi_object {
00570 int32_t count_elements;
00571 int32_t orig_count;
00572 int32_t count_objects;
00573 struct pst_mapi_element **elements;
00574 struct pst_mapi_object *next;
00575 } pst_mapi_object;
00576
00577
00578 typedef struct pst_holder {
00579 char **buf;
00580 FILE *fp;
00581 int base64;
00582 } pst_holder;
00583
00584
00585 typedef struct pst_subblock {
00586 char *buf;
00587 size_t read_size;
00588 size_t i_offset;
00589 } pst_subblock;
00590
00591
00592 typedef struct pst_subblocks {
00593 size_t subblock_count;
00594 pst_subblock *subs;
00595 } pst_subblocks;
00596
00597
00598
00599 int pst_open(pst_file *pf, char *name);
00600 int pst_close(pst_file *pf);
00601 pst_desc_tree * pst_getTopOfFolders(pst_file *pf, pst_item *root);
00602 size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp);
00603 size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp);
00604 int pst_load_index (pst_file *pf);
00605 pst_desc_tree* pst_getNextDptr(pst_desc_tree* d);
00606 int pst_load_extended_attributes(pst_file *pf);
00607 pst_item* pst_getItem(pst_file *pf, pst_desc_tree *d_ptr);
00608 pst_item* pst_parse_item (pst_file *pf, pst_desc_tree *d_ptr, pst_id2_tree *m_head);
00609 void pst_freeItem(pst_item *item);
00610 pst_index_ll* pst_getID(pst_file* pf, uint64_t i_id);
00611 int pst_decrypt(uint64_t id, char *buf, size_t size, unsigned char type);
00612 size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t id, char **b);
00613 size_t pst_ff_getIDblock(pst_file *pf, uint64_t id, char** b);
00614 size_t pst_fwrite(const void*ptr, size_t size, size_t nmemb, FILE*stream);
00615 char * pst_rfc2426_escape(char *str);
00616 char * pst_rfc2425_datetime_format(FILETIME *ft);
00617 char * pst_rfc2445_datetime_format(FILETIME *ft);
00618
00619
00620 const char* pst_codepage(int cp);
00621 const char* pst_default_charset(pst_item *item);
00622 void pst_convert_utf8_null(pst_item *item, pst_string *str);
00623 void pst_convert_utf8(pst_item *item, pst_string *str);
00624
00625
00626
00627
00628 #ifdef _MSC_VER
00629 #pragma pack(pop)
00630 #endif
00631 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
00632 #pragma pack()
00633 #endif
00634
00635
00636
00637 #endif