Main Page | 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 
00037 // defines types of possible encryption
00038 #define PST_NO_ENCRYPT   0
00039 #define PST_COMP_ENCRYPT 1
00040 #define PST_ENCRYPT      2
00041 
00042 // defines different types of mappings
00043 #define PST_MAP_ATTRIB (uint32_t)1
00044 #define PST_MAP_HEADER (uint32_t)2
00045 
00046 // define my custom email attributes.
00047 #define PST_ATTRIB_HEADER -1
00048 
00049 // defines types of free/busy values for appointment->showas
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 // defines labels for appointment->label
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 // define type of recuring event
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 typedef struct pst_entryid {
00077     int32_t u1;
00078     char entryid[16];
00079     uint32_t id;
00080 } pst_entryid;
00081 
00082 
00083 typedef struct pst_index_ll {
00084     uint64_t i_id;
00085     uint64_t offset;
00086     uint64_t size;
00087     int64_t  u1;
00088     struct pst_index_ll *next;
00089 } pst_index_ll;
00090 
00091 
00092 typedef struct pst_id2_tree {
00093     uint64_t            id2;
00094     pst_index_ll        *id;
00095     struct pst_id2_tree *child;
00096     struct pst_id2_tree *next;
00097 } pst_id2_tree;
00098 
00099 
00100 typedef struct pst_desc_tree {
00101     uint64_t              d_id;
00102     uint64_t              parent_d_id;
00103     pst_index_ll         *desc;
00104     pst_index_ll         *assoc_tree;
00105     int32_t               no_child;
00106     struct pst_desc_tree *prev;
00107     struct pst_desc_tree *next;
00108     struct pst_desc_tree *parent;
00109     struct pst_desc_tree *child;
00110     struct pst_desc_tree *child_tail;
00111 } pst_desc_tree;
00112 
00113 
00118 typedef struct pst_string {
00121     int     is_utf8;
00122     char   *str;
00123 } pst_string;
00124 
00125 
00127 typedef struct pst_binary {
00128     size_t  size;
00129     char   *data;
00130 } pst_binary;
00131 
00132 
00135 typedef struct pst_item_email {
00137     FILETIME   *arrival_date;
00142     int         autoforward;
00144     pst_string  cc_address;
00146     pst_string  bcc_address;
00148     pst_binary  conversation_index;
00152     int         conversion_prohibited;
00156     int         delete_after_submit;
00160     int         delivery_report;
00162     pst_binary  encrypted_body;
00164     pst_binary  encrypted_htmlbody;
00166     pst_string  header;
00168     pst_string  htmlbody;
00173     int32_t     importance;
00175     pst_string  in_reply_to;
00179     int         message_cc_me;
00183     int         message_recip_me;
00187     int         message_to_me;
00189     pst_string  messageid;
00195     int32_t     original_sensitivity;
00197     pst_string  original_bcc;
00199     pst_string  original_cc;
00201     pst_string  original_to;
00203     pst_string  outlook_recipient;
00205     pst_string  outlook_recipient_name;
00207     pst_string  outlook_recipient2;
00209     pst_string  outlook_sender;
00211     pst_string  outlook_sender_name;
00213     pst_string  outlook_sender2;
00219     int32_t     priority;
00221     pst_string  processed_subject;
00225     int         read_receipt;
00227     pst_string  recip_access;
00229     pst_string  recip_address;
00231     pst_string  recip2_access;
00233     pst_string  recip2_address;
00237     int         reply_requested;
00239     pst_string  reply_to;
00241     pst_string  return_path_address;
00245     int32_t     rtf_body_char_count;
00247     int32_t     rtf_body_crc;
00251     pst_string  rtf_body_tag;
00255     pst_binary  rtf_compressed;
00263     int         rtf_in_sync;
00266     int32_t     rtf_ws_prefix_count;
00269     int32_t     rtf_ws_trailing_count;
00271     pst_string  sender_access;
00273     pst_string  sender_address;
00275     pst_string  sender2_access;
00277     pst_string  sender2_address;
00283     int32_t     sensitivity;
00285     FILETIME    *sent_date;
00287     pst_entryid *sentmail_folder;
00289     pst_string  sentto_address;
00291     pst_string  report_text;
00293     FILETIME   *report_time;
00295     int32_t     ndr_reason_code;
00297     int32_t     ndr_diag_code;
00299     pst_string  supplementary_info;
00301     int32_t     ndr_status_code;
00302 } pst_item_email;
00303 
00304 
00307 typedef struct pst_item_folder {
00309     int32_t  item_count;
00311     int32_t  unseen_item_count;
00315     int32_t  assoc_count;
00320     int      subfolder;
00321 } pst_item_folder;
00322 
00323 
00326 typedef struct pst_item_message_store {
00328     pst_entryid *top_of_personal_folder;
00330     pst_entryid *default_outbox_folder;
00332     pst_entryid *deleted_items_folder;
00334     pst_entryid *sent_items_folder;
00336     pst_entryid *user_views_folder;
00338     pst_entryid *common_view_folder;
00340     pst_entryid *search_root_folder;
00342     pst_entryid *top_of_folder;
00353     int32_t valid_mask;
00355     int32_t pwd_chksum;
00356 } pst_item_message_store;
00357 
00358 
00361 typedef struct pst_item_contact {
00363     pst_string  account_name;
00365     pst_string  address1;
00367     pst_string  address1a;
00369     pst_string  address1_desc;
00371     pst_string  address1_transport;
00373     pst_string  address2;
00375     pst_string  address2a;
00377     pst_string  address2_desc;
00379     pst_string  address2_transport;
00381     pst_string  address3;
00383     pst_string  address3a;
00385     pst_string  address3_desc;
00387     pst_string  address3_transport;
00389     pst_string  assistant_name;
00391     pst_string  assistant_phone;
00393     pst_string  billing_information;
00395     FILETIME   *birthday;
00397     pst_string  business_address;
00399     pst_string  business_city;
00401     pst_string  business_country;
00403     pst_string  business_fax;
00405     pst_string  business_homepage;
00407     pst_string  business_phone;
00409     pst_string  business_phone2;
00411     pst_string  business_po_box;
00413     pst_string  business_postal_code;
00415     pst_string  business_state;
00417     pst_string  business_street;
00419     pst_string  callback_phone;
00421     pst_string  car_phone;
00423     pst_string  company_main_phone;
00425     pst_string  company_name;
00427     pst_string  computer_name;
00429     pst_string  customer_id;
00431     pst_string  def_postal_address;
00433     pst_string  department;
00435     pst_string  display_name_prefix;
00437     pst_string  first_name;
00439     pst_string  followup;
00441     pst_string  free_busy_address;
00443     pst_string  ftp_site;
00445     pst_string  fullname;
00450     int16_t     gender;
00452     pst_string  gov_id;
00454     pst_string  hobbies;
00456     pst_string  home_address;
00458     pst_string  home_city;
00460     pst_string  home_country;
00462     pst_string  home_fax;
00464     pst_string  home_phone;
00466     pst_string  home_phone2;
00468     pst_string  home_po_box;
00470     pst_string  home_postal_code;
00472     pst_string  home_state;
00474     pst_string  home_street;
00476     pst_string  initials;
00478     pst_string  isdn_phone;
00480     pst_string  job_title;
00482     pst_string  keyword;
00484     pst_string  language;
00486     pst_string  location;
00490     int         mail_permission;
00492     pst_string  manager_name;
00494     pst_string  middle_name;
00496     pst_string  mileage;
00498     pst_string  mobile_phone;
00500     pst_string  nickname;
00502     pst_string  office_loc;
00504     pst_string  common_name;
00506     pst_string  org_id;
00508     pst_string  other_address;
00510     pst_string  other_city;
00512     pst_string  other_country;
00514     pst_string  other_phone;
00516     pst_string  other_po_box;
00518     pst_string  other_postal_code;
00520     pst_string  other_state;
00522     pst_string  other_street;
00524     pst_string  pager_phone;
00526     pst_string  personal_homepage;
00528     pst_string  pref_name;
00530     pst_string  primary_fax;
00532     pst_string  primary_phone;
00534     pst_string  profession;
00536     pst_string  radio_phone;
00540     int         rich_text;
00542     pst_string  spouse_name;
00544     pst_string  suffix;
00546     pst_string  surname;
00548     pst_string  telex;
00550     pst_string  transmittable_display_name;
00552     pst_string  ttytdd_phone;
00554     FILETIME   *wedding_anniversary;
00556     pst_string  work_address_street;
00558     pst_string  work_address_city;
00560     pst_string  work_address_state;
00562     pst_string  work_address_postalcode;
00564     pst_string  work_address_country;
00566     pst_string  work_address_postofficebox;
00567 } pst_item_contact;
00568 
00569 
00572 typedef struct pst_item_attach {
00574     pst_string      filename1;
00576     pst_string      filename2;
00578     pst_string      mimetype;
00580     pst_binary      data;
00582     uint64_t        id2_val;
00584     uint64_t        i_id;
00586     pst_id2_tree    *id2_head;
00595     int32_t         method;
00597     int32_t         position;
00599     int32_t         sequence;
00600     struct pst_item_attach *next;
00601 } pst_item_attach;
00602 
00603 
00605 typedef struct pst_item_extra_field {
00606     char   *field_name;
00607     char   *value;
00608     struct pst_item_extra_field *next;
00609 } pst_item_extra_field;
00610 
00611 
00614 typedef struct pst_item_journal {
00616     FILETIME   *start;
00618     FILETIME   *end;
00620     pst_string  type;
00622     pst_string  description;
00623 } pst_item_journal;
00624 
00625 
00629 typedef struct pst_recurrence {
00631     uint32_t    signature;
00636     uint32_t    type;
00643     uint32_t    sub_type;
00645     uint32_t    parm1;
00646     uint32_t    parm2;
00647     uint32_t    parm3;
00648     uint32_t    parm4;
00649     uint32_t    parm5;
00655     uint32_t    termination;
00657     uint32_t    interval;
00659     uint32_t    bydaymask;
00661     uint32_t    dayofmonth;
00663     uint32_t    monthofyear;
00665     uint32_t    position;
00667     uint32_t    count;
00668     // there is more data, including the termination date,
00669     // but we can get that from other mapi elements.
00670 } pst_recurrence;
00671 
00672 
00675 typedef struct pst_item_appointment {
00677     FILETIME   *start;
00679     FILETIME   *end;
00681     pst_string  location;
00685     int         alarm;
00687     FILETIME   *reminder;
00689     int32_t     alarm_minutes;
00691     pst_string  alarm_filename;
00693     pst_string  timezonestring;
00699     int32_t     showas;
00712     int32_t     label;
00716     int         all_day;
00720     int         is_recurring;
00727     int32_t     recurrence_type;
00729     pst_string  recurrence_description;
00731     pst_binary  recurrence_data;
00733     FILETIME   *recurrence_start;
00735     FILETIME   *recurrence_end;
00736 } pst_item_appointment;
00737 
00738 
00742 typedef struct pst_item {
00744     pst_item_email         *email;
00746     pst_item_folder        *folder;
00748     pst_item_contact       *contact;
00750     pst_item_attach        *attach;
00752     pst_item_message_store *message_store;
00754     pst_item_extra_field   *extra_fields;
00756     pst_item_journal       *journal;
00758     pst_item_appointment   *appointment;
00769     int         type;
00771     char       *ascii_type;
00783     int32_t     flags;
00785     pst_string  file_as;
00787     pst_string  comment;
00789     pst_string  body_charset;
00791     pst_string  body;
00793     pst_string  subject;
00795     int32_t     internet_cpid;
00797     int32_t     message_codepage;
00799     int32_t     message_size;
00801     pst_string  outlook_version;
00803     pst_binary  record_key;
00805     pst_binary  predecessor_change;
00809     int         response_requested;
00811     FILETIME   *create_date;
00813     FILETIME   *modify_date;
00817     int         private_member;
00818 } pst_item;
00819 
00820 
00829 typedef struct pst_x_attrib_ll {
00833     uint32_t mytype;
00835     uint32_t map;
00837     void     *data;
00839     struct pst_x_attrib_ll *next;
00840 } pst_x_attrib_ll;
00841 
00842 
00844 typedef struct pst_block_recorder {
00845     struct pst_block_recorder  *next;
00846     int64_t                     offset;
00847     size_t                      size;
00848     int                         readcount;
00849 } pst_block_recorder;
00850 
00851 
00852 typedef struct pst_file {
00854     FILE*   fp;
00856     char*   cwd;
00858     char*   fname;
00860     pst_index_ll *i_head, *i_tail;
00862     pst_desc_tree  *d_head, *d_tail;
00864     pst_x_attrib_ll *x_head;
00868     pst_block_recorder *block_head;
00869 
00872     int do_read64;
00874     uint64_t index1;
00876     uint64_t index1_back;
00878     uint64_t index2;
00880     uint64_t index2_back;
00882     uint64_t size;
00886     unsigned char encryption;
00892     unsigned char ind_type;
00893 } pst_file;
00894 
00895 
00902 int             pst_open(pst_file *pf, const char *name);
00903 
00904 
00909 int             pst_reopen(pst_file *pf);
00910 
00911 
00917 int             pst_load_index (pst_file *pf);
00918 
00919 
00924 int             pst_load_extended_attributes(pst_file *pf);
00925 
00926 
00930 int             pst_close(pst_file *pf);
00931 
00932 
00938 pst_desc_tree*  pst_getTopOfFolders(pst_file *pf, const pst_item *root);
00939 
00940 
00947 pst_binary      pst_attach_to_mem(pst_file *pf, pst_item_attach *attach);
00948 
00949 
00955 size_t          pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp);
00956 
00957 
00963 size_t          pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp);
00964 
00965 
00970 pst_desc_tree*  pst_getNextDptr(pst_desc_tree* d);
00971 
00972 
00980 pst_item*       pst_parse_item (pst_file *pf, pst_desc_tree *d_ptr, pst_id2_tree *m_head);
00981 
00982 
00986 void            pst_freeItem(pst_item *item);
00987 
00988 
00994 pst_index_ll*   pst_getID(pst_file* pf, uint64_t i_id);
00995 
00996 
01004 size_t          pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf);
01005 
01006 
01014 size_t          pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream);
01015 
01016 
01025 char*           pst_rfc2426_escape(char* str, char** result, size_t* resultlen);
01026 
01027 
01035 char*           pst_rfc2425_datetime_format(const FILETIME* ft, int buflen, char* result);
01036 
01037 
01044 char*           pst_rfc2445_datetime_format(const FILETIME* ft, int buflen, char* result);
01045 
01046 
01052 char*           pst_rfc2445_datetime_format_now(int buflen, char* result);
01053 
01054 
01062 const char*     pst_default_charset(pst_item *item, int buflen, char* result);
01063 
01064 
01069 void            pst_convert_utf8_null(pst_item *item, pst_string *str);
01070 
01071 
01076 void            pst_convert_utf8(pst_item *item, pst_string *str);
01077 
01078 
01083 pst_recurrence* pst_convert_recurrence(pst_item_appointment* appt);
01084 
01085 
01089 void            pst_free_recurrence(pst_recurrence* r);
01090 
01091 
01092 
01093 // switch from maximal packing back to default packing
01094 // undo the packing from the beginning of this file
01095 #ifdef _MSC_VER
01096     #pragma pack(pop)
01097 #endif
01098 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
01099     #pragma pack()
01100 #endif
01101 
01102 
01103 
01104 #endif

Generated on Tue Jun 23 20:30:41 2009 for libpst.so.4 by  doxygen 1.3.9.1