Main Page | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

libpst.h

Go to the documentation of this file.
00001 /***
00002  * libpst.h
00003  * Part of LibPST project
00004  * Written by David Smith
00005  *            dave.s@earthcorp.com
00006  */
00007 // LibPST - Library for Accessing Outlook .pst files
00008 // Dave Smith - davesmith@users.sourceforge.net
00009 
00010 #ifndef __PST_LIBPST_H
00011 #define __PST_LIBPST_H
00012 
00013 #include "common.h"
00014 
00015 
00016 // switch to maximal packing for all structures in the libpst interface
00017 // this is reverted at the end of this file
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 // defines types of possible encryption
00037 #define PST_NO_ENCRYPT   0
00038 #define PST_COMP_ENCRYPT 1
00039 #define PST_ENCRYPT      2
00040 
00041 // defines different types of mappings
00042 #define PST_MAP_ATTRIB (uint32_t)1
00043 #define PST_MAP_HEADER (uint32_t)2
00044 
00045 // define my custom email attributes.
00046 #define PST_ATTRIB_HEADER -1
00047 
00048 // defines types of free/busy values for appointment->showas
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 // defines labels for appointment->label
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 // define type of recuring event
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 // define attachment types
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 // define flags
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     struct pst_index_ll *next;
00109 } pst_index_ll;
00110 
00111 
00112 typedef struct pst_id2_tree {
00113     uint64_t            id2;
00114     pst_index_ll        *id;
00115     struct pst_id2_tree *child;
00116     struct pst_id2_tree *next;
00117 } pst_id2_tree;
00118 
00119 
00120 typedef struct pst_desc_tree {
00121     uint64_t              d_id;
00122     uint64_t              parent_d_id;
00123     pst_index_ll         *desc;
00124     pst_index_ll         *assoc_tree;
00125     int32_t               no_child;
00126     struct pst_desc_tree *prev;
00127     struct pst_desc_tree *next;
00128     struct pst_desc_tree *parent;
00129     struct pst_desc_tree *child;
00130     struct pst_desc_tree *child_tail;
00131 } pst_desc_tree;
00132 
00133 
00138 typedef struct pst_string {
00141     int     is_utf8;
00142     char   *str;
00143 } pst_string;
00144 
00145 
00147 typedef struct pst_binary {
00148     size_t  size;
00149     char   *data;
00150 } pst_binary;
00151 
00152 
00155 typedef struct pst_item_email {
00157     FILETIME   *arrival_date;
00162     int         autoforward;
00164     pst_string  cc_address;
00166     pst_string  bcc_address;
00168     pst_binary  conversation_index;
00172     int         conversion_prohibited;
00176     int         delete_after_submit;
00180     int         delivery_report;
00182     pst_binary  encrypted_body;
00184     pst_binary  encrypted_htmlbody;
00186     pst_string  header;
00188     pst_string  htmlbody;
00193     int32_t     importance;
00195     pst_string  in_reply_to;
00199     int         message_cc_me;
00203     int         message_recip_me;
00207     int         message_to_me;
00209     pst_string  messageid;
00215     int32_t     original_sensitivity;
00217     pst_string  original_bcc;
00219     pst_string  original_cc;
00221     pst_string  original_to;
00223     pst_string  outlook_recipient;
00225     pst_string  outlook_recipient_name;
00227     pst_string  outlook_recipient2;
00229     pst_string  outlook_sender;
00231     pst_string  outlook_sender_name;
00233     pst_string  outlook_sender2;
00239     int32_t     priority;
00241     pst_string  processed_subject;
00245     int         read_receipt;
00247     pst_string  recip_access;
00249     pst_string  recip_address;
00251     pst_string  recip2_access;
00253     pst_string  recip2_address;
00257     int         reply_requested;
00259     pst_string  reply_to;
00261     pst_string  return_path_address;
00265     int32_t     rtf_body_char_count;
00267     int32_t     rtf_body_crc;
00271     pst_string  rtf_body_tag;
00275     pst_binary  rtf_compressed;
00283     int         rtf_in_sync;
00286     int32_t     rtf_ws_prefix_count;
00289     int32_t     rtf_ws_trailing_count;
00291     pst_string  sender_access;
00293     pst_string  sender_address;
00295     pst_string  sender2_access;
00297     pst_string  sender2_address;
00303     int32_t     sensitivity;
00305     FILETIME    *sent_date;
00307     pst_entryid *sentmail_folder;
00309     pst_string  sentto_address;
00311     pst_string  report_text;
00313     FILETIME   *report_time;
00315     int32_t     ndr_reason_code;
00317     int32_t     ndr_diag_code;
00319     pst_string  supplementary_info;
00321     int32_t     ndr_status_code;
00322 } pst_item_email;
00323 
00324 
00327 typedef struct pst_item_folder {
00329     int32_t  item_count;
00331     int32_t  unseen_item_count;
00335     int32_t  assoc_count;
00340     int      subfolder;
00341 } pst_item_folder;
00342 
00343 
00346 typedef struct pst_item_message_store {
00348     pst_entryid *top_of_personal_folder;
00350     pst_entryid *default_outbox_folder;
00352     pst_entryid *deleted_items_folder;
00354     pst_entryid *sent_items_folder;
00356     pst_entryid *user_views_folder;
00358     pst_entryid *common_view_folder;
00360     pst_entryid *search_root_folder;
00362     pst_entryid *top_of_folder;
00373     int32_t valid_mask;
00375     int32_t pwd_chksum;
00376 } pst_item_message_store;
00377 
00378 
00381 typedef struct pst_item_contact {
00383     pst_string  account_name;
00385     pst_string  address1;
00387     pst_string  address1a;
00389     pst_string  address1_desc;
00391     pst_string  address1_transport;
00393     pst_string  address2;
00395     pst_string  address2a;
00397     pst_string  address2_desc;
00399     pst_string  address2_transport;
00401     pst_string  address3;
00403     pst_string  address3a;
00405     pst_string  address3_desc;
00407     pst_string  address3_transport;
00409     pst_string  assistant_name;
00411     pst_string  assistant_phone;
00413     pst_string  billing_information;
00415     FILETIME   *birthday;
00417     pst_string  business_address;
00419     pst_string  business_city;
00421     pst_string  business_country;
00423     pst_string  business_fax;
00425     pst_string  business_homepage;
00427     pst_string  business_phone;
00429     pst_string  business_phone2;
00431     pst_string  business_po_box;
00433     pst_string  business_postal_code;
00435     pst_string  business_state;
00437     pst_string  business_street;
00439     pst_string  callback_phone;
00441     pst_string  car_phone;
00443     pst_string  company_main_phone;
00445     pst_string  company_name;
00447     pst_string  computer_name;
00449     pst_string  customer_id;
00451     pst_string  def_postal_address;
00453     pst_string  department;
00455     pst_string  display_name_prefix;
00457     pst_string  first_name;
00459     pst_string  followup;
00461     pst_string  free_busy_address;
00463     pst_string  ftp_site;
00465     pst_string  fullname;
00470     int16_t     gender;
00472     pst_string  gov_id;
00474     pst_string  hobbies;
00476     pst_string  home_address;
00478     pst_string  home_city;
00480     pst_string  home_country;
00482     pst_string  home_fax;
00484     pst_string  home_phone;
00486     pst_string  home_phone2;
00488     pst_string  home_po_box;
00490     pst_string  home_postal_code;
00492     pst_string  home_state;
00494     pst_string  home_street;
00496     pst_string  initials;
00498     pst_string  isdn_phone;
00500     pst_string  job_title;
00502     pst_string  keyword;
00504     pst_string  language;
00506     pst_string  location;
00510     int         mail_permission;
00512     pst_string  manager_name;
00514     pst_string  middle_name;
00516     pst_string  mileage;
00518     pst_string  mobile_phone;
00520     pst_string  nickname;
00522     pst_string  office_loc;
00524     pst_string  common_name;
00526     pst_string  org_id;
00528     pst_string  other_address;
00530     pst_string  other_city;
00532     pst_string  other_country;
00534     pst_string  other_phone;
00536     pst_string  other_po_box;
00538     pst_string  other_postal_code;
00540     pst_string  other_state;
00542     pst_string  other_street;
00544     pst_string  pager_phone;
00546     pst_string  personal_homepage;
00548     pst_string  pref_name;
00550     pst_string  primary_fax;
00552     pst_string  primary_phone;
00554     pst_string  profession;
00556     pst_string  radio_phone;
00560     int         rich_text;
00562     pst_string  spouse_name;
00564     pst_string  suffix;
00566     pst_string  surname;
00568     pst_string  telex;
00570     pst_string  transmittable_display_name;
00572     pst_string  ttytdd_phone;
00574     FILETIME   *wedding_anniversary;
00576     pst_string  work_address_street;
00578     pst_string  work_address_city;
00580     pst_string  work_address_state;
00582     pst_string  work_address_postalcode;
00584     pst_string  work_address_country;
00586     pst_string  work_address_postofficebox;
00587 } pst_item_contact;
00588 
00589 
00592 typedef struct pst_item_attach {
00594     pst_string      filename1;
00596     pst_string      filename2;
00598     pst_string      mimetype;
00600     pst_binary      data;
00602     uint64_t        id2_val;
00604     uint64_t        i_id;
00606     pst_id2_tree    *id2_head;
00615     int32_t         method;
00617     int32_t         position;
00619     int32_t         sequence;
00620     struct pst_item_attach *next;
00621 } pst_item_attach;
00622 
00623 
00625 typedef struct pst_item_extra_field {
00626     char   *field_name;
00627     char   *value;
00628     struct pst_item_extra_field *next;
00629 } pst_item_extra_field;
00630 
00631 
00634 typedef struct pst_item_journal {
00636     FILETIME   *start;
00638     FILETIME   *end;
00640     pst_string  type;
00642     pst_string  description;
00643 } pst_item_journal;
00644 
00645 
00649 typedef struct pst_recurrence {
00651     uint32_t    signature;
00656     uint32_t    type;
00663     uint32_t    sub_type;
00665     uint32_t    parm1;
00666     uint32_t    parm2;
00667     uint32_t    parm3;
00668     uint32_t    parm4;
00669     uint32_t    parm5;
00675     uint32_t    termination;
00677     uint32_t    interval;
00679     uint32_t    bydaymask;
00681     uint32_t    dayofmonth;
00683     uint32_t    monthofyear;
00685     uint32_t    position;
00687     uint32_t    count;
00688     // there is more data, including the termination date,
00689     // but we can get that from other mapi elements.
00690 } pst_recurrence;
00691 
00692 
00695 typedef struct pst_item_appointment {
00697     FILETIME   *start;
00699     FILETIME   *end;
00701     pst_string  location;
00705     int         alarm;
00707     FILETIME   *reminder;
00709     int32_t     alarm_minutes;
00711     pst_string  alarm_filename;
00713     pst_string  timezonestring;
00719     int32_t     showas;
00732     int32_t     label;
00736     int         all_day;
00740     int         is_recurring;
00747     int32_t     recurrence_type;
00749     pst_string  recurrence_description;
00751     pst_binary  recurrence_data;
00753     FILETIME   *recurrence_start;
00755     FILETIME   *recurrence_end;
00756 } pst_item_appointment;
00757 
00758 
00762 typedef struct pst_item {
00764     pst_item_email         *email;
00766     pst_item_folder        *folder;
00768     pst_item_contact       *contact;
00770     pst_item_attach        *attach;
00772     pst_item_message_store *message_store;
00774     pst_item_extra_field   *extra_fields;
00776     pst_item_journal       *journal;
00778     pst_item_appointment   *appointment;
00789     int         type;
00791     char       *ascii_type;
00803     int32_t     flags;
00805     pst_string  file_as;
00807     pst_string  comment;
00809     pst_string  body_charset;
00811     pst_string  body;
00813     pst_string  subject;
00815     int32_t     internet_cpid;
00817     int32_t     message_codepage;
00819     int32_t     message_size;
00821     pst_string  outlook_version;
00823     pst_binary  record_key;
00825     pst_binary  predecessor_change;
00829     int         response_requested;
00831     FILETIME   *create_date;
00833     FILETIME   *modify_date;
00837     int         private_member;
00838 } pst_item;
00839 
00840 
00849 typedef struct pst_x_attrib_ll {
00853     uint32_t mytype;
00855     uint32_t map;
00857     void     *data;
00859     struct pst_x_attrib_ll *next;
00860 } pst_x_attrib_ll;
00861 
00862 
00864 typedef struct pst_block_recorder {
00865     struct pst_block_recorder  *next;
00866     int64_t                     offset;
00867     size_t                      size;
00868     int                         readcount;
00869 } pst_block_recorder;
00870 
00871 
00872 typedef struct pst_file {
00874     FILE*   fp;
00876     char*   cwd;
00878     char*   fname;
00880     pst_index_ll *i_head, *i_tail;
00882     pst_desc_tree  *d_head, *d_tail;
00884     pst_x_attrib_ll *x_head;
00888     pst_block_recorder *block_head;
00889 
00892     int do_read64;
00894     uint64_t index1;
00896     uint64_t index1_back;
00898     uint64_t index2;
00900     uint64_t index2_back;
00902     uint64_t size;
00906     unsigned char encryption;
00912     unsigned char ind_type;
00913 } pst_file;
00914 
00915 
00922 int             pst_open(pst_file *pf, const char *name);
00923 
00924 
00929 int             pst_reopen(pst_file *pf);
00930 
00931 
00937 int             pst_load_index (pst_file *pf);
00938 
00939 
00944 int             pst_load_extended_attributes(pst_file *pf);
00945 
00946 
00950 int             pst_close(pst_file *pf);
00951 
00952 
00958 pst_desc_tree*  pst_getTopOfFolders(pst_file *pf, const pst_item *root);
00959 
00960 
00967 pst_binary      pst_attach_to_mem(pst_file *pf, pst_item_attach *attach);
00968 
00969 
00975 size_t          pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp);
00976 
00977 
00983 size_t          pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp);
00984 
00985 
00990 pst_desc_tree*  pst_getNextDptr(pst_desc_tree* d);
00991 
00992 
01000 pst_item*       pst_parse_item (pst_file *pf, pst_desc_tree *d_ptr, pst_id2_tree *m_head);
01001 
01002 
01006 void            pst_freeItem(pst_item *item);
01007 
01008 
01014 pst_index_ll*   pst_getID(pst_file* pf, uint64_t i_id);
01015 
01016 
01024 size_t          pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf);
01025 
01026 
01034 size_t          pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream);
01035 
01036 
01045 char*           pst_rfc2426_escape(char* str, char** result, size_t* resultlen);
01046 
01047 
01055 char*           pst_rfc2425_datetime_format(const FILETIME* ft, int buflen, char* result);
01056 
01057 
01064 char*           pst_rfc2445_datetime_format(const FILETIME* ft, int buflen, char* result);
01065 
01066 
01072 char*           pst_rfc2445_datetime_format_now(int buflen, char* result);
01073 
01074 
01082 const char*     pst_default_charset(pst_item *item, int buflen, char* result);
01083 
01084 
01088 void            pst_rfc2231(pst_string *str);
01089 
01090 
01096 void            pst_rfc2047(pst_item *item, pst_string *str, int needs_quote);
01097 
01098 
01103 void            pst_convert_utf8_null(pst_item *item, pst_string *str);
01104 
01105 
01110 void            pst_convert_utf8(pst_item *item, pst_string *str);
01111 
01112 
01117 pst_recurrence* pst_convert_recurrence(pst_item_appointment* appt);
01118 
01119 
01123 void            pst_free_recurrence(pst_recurrence* r);
01124 
01125 
01126 
01127 // switch from maximal packing back to default packing
01128 // undo the packing from the beginning of this file
01129 #ifdef _MSC_VER
01130     #pragma pack(pop)
01131 #endif
01132 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
01133     #pragma pack()
01134 #endif
01135 
01136 
01137 
01138 #endif

Generated on Sun Jul 10 16:52:28 2011 for 'LibPst' by  doxygen 1.3.9.1