00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef LIBPST_H
00011 #define 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_ENC 0
00037 #define PST_ENC 1
00038
00039
00040 #define PST_NO_ENCRYPT 0
00041 #define PST_COMP_ENCRYPT 1
00042 #define PST_ENCRYPT 2
00043
00044
00045 #define PST_MAP_ATTRIB (uint32_t)1
00046 #define PST_MAP_HEADER (uint32_t)2
00047
00048
00049 #define PST_ATTRIB_HEADER -1
00050
00051
00052 #define PST_FREEBUSY_FREE 0
00053 #define PST_FREEBUSY_TENTATIVE 1
00054 #define PST_FREEBUSY_BUSY 2
00055 #define PST_FREEBUSY_OUT_OF_OFFICE 3
00056
00057
00058 #define PST_APP_LABEL_NONE 0 // None
00059 #define PST_APP_LABEL_IMPORTANT 1 // Important
00060 #define PST_APP_LABEL_BUSINESS 2 // Business
00061 #define PST_APP_LABEL_PERSONAL 3 // Personal
00062 #define PST_APP_LABEL_VACATION 4 // Vacation
00063 #define PST_APP_LABEL_MUST_ATTEND 5 // Must Attend
00064 #define PST_APP_LABEL_TRAVEL_REQ 6 // Travel Required
00065 #define PST_APP_LABEL_NEEDS_PREP 7 // Needs Preparation
00066 #define PST_APP_LABEL_BIRTHDAY 8 // Birthday
00067 #define PST_APP_LABEL_ANNIVERSARY 9 // Anniversary
00068 #define PST_APP_LABEL_PHONE_CALL 10// Phone Call
00069
00070
00071 #define PST_APP_RECUR_NONE 0
00072 #define PST_APP_RECUR_DAILY 1
00073 #define PST_APP_RECUR_WEEKLY 2
00074 #define PST_APP_RECUR_MONTHLY 3
00075 #define PST_APP_RECUR_YEARLY 4
00076
00077
00078 typedef struct pst_misc_6_struct {
00079 int32_t i1;
00080 int32_t i2;
00081 int32_t i3;
00082 int32_t i4;
00083 int32_t i5;
00084 int32_t i6;
00085 } pst_misc_6;
00086
00087
00088 typedef struct pst_entryid_struct {
00089 int32_t u1;
00090 char entryid[16];
00091 uint32_t id;
00092 } pst_entryid;
00093
00094
00095 typedef struct pst_desc_struct32 {
00096 uint32_t d_id;
00097 uint32_t desc_id;
00098 uint32_t list_id;
00099 uint32_t parent_id;
00100 } pst_desc32;
00101
00102
00103 typedef struct pst_desc_structn {
00104 uint64_t d_id;
00105 uint64_t desc_id;
00106 uint64_t list_id;
00107 uint32_t parent_id;
00108 uint32_t u1;
00109 } pst_descn;
00110
00111
00112 typedef struct pst_index_struct32 {
00113 uint32_t id;
00114 uint32_t offset;
00115 uint16_t size;
00116 int16_t u1;
00117 } pst_index32;
00118
00119
00120 typedef struct pst_index_struct {
00121 uint64_t id;
00122 uint64_t offset;
00123 uint16_t size;
00124 int16_t u0;
00125 int32_t u1;
00126 } pst_index;
00127
00128
00129 typedef struct pst_index_tree32 {
00130 uint32_t id;
00131 uint32_t offset;
00132 uint32_t size;
00133 int32_t u1;
00134 struct pst_index_tree * next;
00135 } pst_index_ll32;
00136
00137
00138 typedef struct pst_index_tree {
00139 uint64_t id;
00140 uint64_t offset;
00141 uint64_t size;
00142 int64_t u1;
00143 struct pst_index_tree * next;
00144 } pst_index_ll;
00145
00146
00147 typedef struct pst_index2_tree {
00148 uint64_t id2;
00149 pst_index_ll *id;
00150 struct pst_index2_tree * next;
00151 } pst_index2_ll;
00152
00153
00154 typedef struct pst_desc_tree {
00155 uint64_t id;
00156 uint64_t parent_id;
00157 pst_index_ll * list_index;
00158 pst_index_ll * desc;
00159 int32_t no_child;
00160 struct pst_desc_tree * prev;
00161 struct pst_desc_tree * next;
00162 struct pst_desc_tree * parent;
00163 struct pst_desc_tree * child;
00164 struct pst_desc_tree * child_tail;
00165 } pst_desc_ll;
00166
00167
00168 typedef struct pst_item_email_subject {
00169 int off1;
00170 int off2;
00171 char *subj;
00172 } pst_item_email_subject;
00173
00174
00175 typedef struct pst_item_email {
00176 FILETIME *arrival_date;
00177 int autoforward;
00178 char *body;
00179 char *body_charset;
00180 char *cc_address;
00181 char *bcc_address;
00182 char *common_name;
00183 int32_t conv_index;
00184 int conversion_prohib;
00185 int delete_after_submit;
00186 int delivery_report;
00187 char *encrypted_body;
00188 size_t encrypted_body_size;
00189 char *encrypted_htmlbody;
00190 size_t encrypted_htmlbody_size;
00191 int32_t flag;
00192 char *header;
00193 char *htmlbody;
00194 int32_t importance;
00195 char *in_reply_to;
00196 int message_cc_me;
00197 int message_recip_me;
00198 int message_to_me;
00199 char *messageid;
00200 int32_t orig_sensitivity;
00201 char *original_bcc;
00202 char *original_cc;
00203 char *original_to;
00204 char *outlook_recipient;
00205 char *outlook_recipient_name;
00206 char *outlook_recipient2;
00207 char *outlook_sender;
00208 char *outlook_sender_name;
00209 char *outlook_sender2;
00210 int32_t priority;
00211 char *proc_subject;
00212 int read_receipt;
00213 char *recip_access;
00214 char *recip_address;
00215 char *recip2_access;
00216 char *recip2_address;
00217 int reply_requested;
00218 char *reply_to;
00219 char *return_path_address;
00220 int32_t rtf_body_char_count;
00221 int32_t rtf_body_crc;
00222 char *rtf_body_tag;
00223 char *rtf_compressed;
00224 uint32_t rtf_compressed_size;
00225 int rtf_in_sync;
00226 int32_t rtf_ws_prefix_count;
00227 int32_t rtf_ws_trailing_count;
00228 char *sender_access;
00229 char *sender_address;
00230 char *sender2_access;
00231 char *sender2_address;
00232 int32_t sensitivity;
00233 FILETIME *sent_date;
00234 pst_entryid *sentmail_folder;
00235 char *sentto_address;
00236 pst_item_email_subject *subject;
00237 } pst_item_email;
00238
00239
00240 typedef struct pst_item_folder {
00241 int32_t email_count;
00242 int32_t unseen_email_count;
00243 int32_t assoc_count;
00244 int subfolder;
00245 } pst_item_folder;
00246
00247
00248 typedef struct pst_item_message_store {
00249 pst_entryid *top_of_personal_folder;
00250 pst_entryid *default_outbox_folder;
00251 pst_entryid *deleted_items_folder;
00252 pst_entryid *sent_items_folder;
00253 pst_entryid *user_views_folder;
00254 pst_entryid *common_view_folder;
00255 pst_entryid *search_root_folder;
00256 pst_entryid *top_of_folder;
00257 int32_t valid_mask;
00258 int32_t pwd_chksum;
00259 } pst_item_message_store;
00260
00261
00262 typedef struct pst_item_contact {
00263 char *access_method;
00264 char *account_name;
00265 char *address1;
00266 char *address1a;
00267 char *address1_desc;
00268 char *address1_transport;
00269 char *address2;
00270 char *address2a;
00271 char *address2_desc;
00272 char *address2_transport;
00273 char *address3;
00274 char *address3a;
00275 char *address3_desc;
00276 char *address3_transport;
00277 char *assistant_name;
00278 char *assistant_phone;
00279 char *billing_information;
00280 FILETIME *birthday;
00281 char *business_address;
00282 char *business_city;
00283 char *business_country;
00284 char *business_fax;
00285 char *business_homepage;
00286 char *business_phone;
00287 char *business_phone2;
00288 char *business_po_box;
00289 char *business_postal_code;
00290 char *business_state;
00291 char *business_street;
00292 char *callback_phone;
00293 char *car_phone;
00294 char *company_main_phone;
00295 char *company_name;
00296 char *computer_name;
00297 char *customer_id;
00298 char *def_postal_address;
00299 char *department;
00300 char *display_name_prefix;
00301 char *first_name;
00302 char *followup;
00303 char *free_busy_address;
00304 char *ftp_site;
00305 char *fullname;
00306 int16_t gender;
00307 char *gov_id;
00308 char *hobbies;
00309 char *home_address;
00310 char *home_city;
00311 char *home_country;
00312 char *home_fax;
00313 char *home_phone;
00314 char *home_phone2;
00315 char *home_po_box;
00316 char *home_postal_code;
00317 char *home_state;
00318 char *home_street;
00319 char *initials;
00320 char *isdn_phone;
00321 char *job_title;
00322 char *keyword;
00323 char *language;
00324 char *location;
00325 int mail_permission;
00326 char *manager_name;
00327 char *middle_name;
00328 char *mileage;
00329 char *mobile_phone;
00330 char *nickname;
00331 char *office_loc;
00332 char *org_id;
00333 char *other_address;
00334 char *other_city;
00335 char *other_country;
00336 char *other_phone;
00337 char *other_po_box;
00338 char *other_postal_code;
00339 char *other_state;
00340 char *other_street;
00341 char *pager_phone;
00342 char *personal_homepage;
00343 char *pref_name;
00344 char *primary_fax;
00345 char *primary_phone;
00346 char *profession;
00347 char *radio_phone;
00348 int rich_text;
00349 char *spouse_name;
00350 char *suffix;
00351 char *surname;
00352 char *telex;
00353 char *transmittable_display_name;
00354 char *ttytdd_phone;
00355 FILETIME *wedding_anniversary;
00356 char *work_address_street;
00357 char *work_address_city;
00358 char *work_address_state;
00359 char *work_address_postalcode;
00360 char *work_address_country;
00361 char *work_address_postofficebox;
00362 } pst_item_contact;
00363
00364
00365 typedef struct pst_item_attach {
00366 char *filename1;
00367 char *filename2;
00368 char *mimetype;
00369 char *data;
00370 size_t size;
00371 uint64_t id2_val;
00372 uint64_t id_val;
00373 int32_t method;
00374 int32_t position;
00375 int32_t sequence;
00376 struct pst_item_attach *next;
00377 } pst_item_attach;
00378
00379
00380 typedef struct pst_item_extra_field {
00381 char *field_name;
00382 char *value;
00383 struct pst_item_extra_field *next;
00384 } pst_item_extra_field;
00385
00386
00387 typedef struct pst_item_journal {
00388 FILETIME *end;
00389 FILETIME *start;
00390 char *type;
00391 } pst_item_journal;
00392
00393
00394 typedef struct pst_item_appointment {
00395 FILETIME *end;
00396 char *location;
00397 int alarm;
00398 FILETIME *reminder;
00399 int32_t alarm_minutes;
00400 char *alarm_filename;
00401 FILETIME *start;
00402 char *timezonestring;
00403 int32_t showas;
00404 int32_t label;
00405 int all_day;
00406 char *recurrence;
00407 int32_t recurrence_type;
00408 FILETIME *recurrence_start;
00409 FILETIME *recurrence_end;
00410 } pst_item_appointment;
00411
00412
00413 typedef struct pst_item {
00414 struct pst_item_email *email;
00415 struct pst_item_folder *folder;
00416 struct pst_item_contact *contact;
00417 struct pst_item_attach *attach;
00418 struct pst_item_message_store *message_store;
00419 struct pst_item_extra_field *extra_fields;
00420 struct pst_item_journal *journal;
00421 struct pst_item_appointment *appointment;
00422 int type;
00423 char *ascii_type;
00424 char *file_as;
00425 char *comment;
00426 int32_t message_size;
00427 char *outlook_version;
00428 char *record_key;
00429 size_t record_key_size;
00430 int response_requested;
00431 FILETIME *create_date;
00432 FILETIME *modify_date;
00433 int private_member;
00434 } pst_item;
00435
00436
00437 typedef struct pst_x_attrib_ll {
00438 uint32_t type;
00439 uint32_t mytype;
00440 uint32_t map;
00441 void *data;
00442 struct pst_x_attrib_ll *next;
00443 } pst_x_attrib_ll;
00444
00445
00446 typedef struct pst_block_recorder {
00447 struct pst_block_recorder *next;
00448 int64_t offset;
00449 size_t size;
00450 int readcount;
00451 } pst_block_recorder;
00452
00453
00454 typedef struct pst_file {
00455 pst_index_ll *i_head, *i_tail;
00456 pst_desc_ll *d_head, *d_tail;
00457 pst_x_attrib_ll *x_head;
00458 pst_block_recorder *block_head;
00459
00460
00461
00462 int do_read64;
00463
00464 uint64_t index1;
00465 uint64_t index1_back;
00466 uint64_t index2;
00467 uint64_t index2_back;
00468 FILE * fp;
00469 uint64_t size;
00470 unsigned char encryption;
00471 unsigned char ind_type;
00472 } pst_file;
00473
00474
00475 typedef struct pst_block_offset {
00476 int16_t from;
00477 int16_t to;
00478 } pst_block_offset;
00479
00480
00481 typedef struct pst_block_offset_pointer {
00482 char *from;
00483 char *to;
00484 int needfree;
00485 } pst_block_offset_pointer;
00486
00487
00488 typedef struct pst_num_item {
00489 uint32_t id;
00490 char *data;
00491 uint32_t type;
00492 size_t size;
00493 char *extra;
00494 } pst_num_item;
00495
00496
00497 typedef struct pst_num_array {
00498 int32_t count_item;
00499 int32_t orig_count;
00500 int32_t count_array;
00501 struct pst_num_item ** items;
00502 struct pst_num_array *next;
00503 } pst_num_array;
00504
00505
00506 typedef struct pst_holder {
00507 char **buf;
00508 FILE *fp;
00509 int base64;
00510 } pst_holder;
00511
00512
00513 typedef struct pst_subblock {
00514 char *buf;
00515 size_t read_size;
00516 size_t i_offset;
00517 } pst_subblock;
00518
00519
00520 typedef struct pst_subblocks {
00521 size_t subblock_count;
00522 pst_subblock *subs;
00523 } pst_subblocks;
00524
00525
00526
00527 int pst_open(pst_file *pf, char *name);
00528 int pst_close(pst_file *pf);
00529 pst_desc_ll * pst_getTopOfFolders(pst_file *pf, pst_item *root);
00530 size_t pst_attach_to_mem(pst_file *pf, pst_item_attach *attach, char **b);
00531 size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp);
00532 size_t pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp);
00533 int pst_load_index (pst_file *pf);
00534 pst_desc_ll* pst_getNextDptr(pst_desc_ll* d);
00535 int pst_load_extended_attributes(pst_file *pf);
00536
00537 int pst_build_id_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val);
00538 int pst_build_desc_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val);
00539 pst_item* pst_getItem(pst_file *pf, pst_desc_ll *d_ptr);
00540 pst_item* pst_parse_item (pst_file *pf, pst_desc_ll *d_ptr);
00541 pst_num_array* pst_parse_block(pst_file *pf, uint64_t block_id, pst_index2_ll *i2_head, pst_num_array *na_head);
00542 int pst_process(pst_num_array *list, pst_item *item, pst_item_attach *attach);
00543 void pst_free_list(pst_num_array *list);
00544 void pst_freeItem(pst_item *item);
00545 void pst_free_id2(pst_index2_ll * head);
00546 void pst_free_id (pst_index_ll *head);
00547 void pst_free_desc (pst_desc_ll *head);
00548 void pst_free_xattrib(pst_x_attrib_ll *x);
00549 int pst_getBlockOffsetPointer(pst_file *pf, pst_index2_ll *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p);
00550 int pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p);
00551 pst_index2_ll* pst_build_id2(pst_file *pf, pst_index_ll* list, pst_index2_ll* head_ptr);
00552 pst_index_ll* pst_getID(pst_file* pf, uint64_t id);
00553 pst_index_ll* pst_getID2(pst_index2_ll * ptr, uint64_t id);
00554 pst_desc_ll* pst_getDptr(pst_file *pf, uint64_t id);
00555 size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf);
00556 int pst_decrypt(uint64_t id, char *buf, size_t size, unsigned char type);
00557 uint64_t pst_getIntAt(pst_file *pf, char *buf);
00558 uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos);
00559 size_t pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size);
00560 size_t pst_ff_getIDblock_dec(pst_file *pf, uint64_t id, char **b);
00561 size_t pst_ff_getIDblock(pst_file *pf, uint64_t id, char** b);
00562 size_t pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_index2_ll *id2_head, char** buf);
00563 size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h);
00564 size_t pst_ff_compile_ID(pst_file *pf, uint64_t id, pst_holder *h, size_t size);
00565
00566 int pst_strincmp(char *a, char *b, size_t x);
00567 int pst_stricmp(char *a, char *b);
00568 size_t pst_fwrite(const void*ptr, size_t size, size_t nmemb, FILE*stream);
00569 char * pst_wide_to_single(char *wt, size_t size);
00570
00571 char * pst_rfc2426_escape(char *str);
00572 int pst_chr_count(char *str, char x);
00573 char * pst_rfc2425_datetime_format(FILETIME *ft);
00574 char * pst_rfc2445_datetime_format(FILETIME *ft);
00575
00576 void pst_printDptr(pst_file *pf, pst_desc_ll *ptr);
00577 void pst_printIDptr(pst_file* pf);
00578 void pst_printID2ptr(pst_index2_ll *ptr);
00579
00580
00581
00582
00583 #ifdef _MSC_VER
00584 #pragma pack(pop)
00585 #endif
00586 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
00587 #pragma pack()
00588 #endif
00589
00590
00591
00592 #endif // defined LIBPST_H