libpst.so.4: libpst/libpst.h Source File

# 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
    00323     // elements added for .msg processing
    00325     pst_string  outlook_received_name1;
    00327     pst_string  outlook_sender_name2;
    00329     pst_string  outlook_normalized_subject;
    00331     pst_string  outlook_search_key;
    00332 } pst_item_email;
    00333
    00334
    00337 typedef struct pst_item_folder {
    00339     int32_t  item_count;
    00341     int32_t  unseen_item_count;
    00345     int32_t  assoc_count;
    00350     int      subfolder;
    00351 } pst_item_folder;
    00352
    00353
    00356 typedef struct pst_item_message_store {
    00358     pst_entryid *top_of_personal_folder;
    00360     pst_entryid *default_outbox_folder;
    00362     pst_entryid *deleted_items_folder;
    00364     pst_entryid *sent_items_folder;
    00366     pst_entryid *user_views_folder;
    00368     pst_entryid *common_view_folder;
    00370     pst_entryid *search_root_folder;
    00372     pst_entryid *top_of_folder;
    00383     int32_t valid_mask;
    00385     int32_t pwd_chksum;
    00386 } pst_item_message_store;
    00387
    00388
    00391 typedef struct pst_item_contact {
    00393     pst_string  account_name;
    00395     pst_string  address1;
    00397     pst_string  address1a;
    00399     pst_string  address1_desc;
    00401     pst_string  address1_transport;
    00403     pst_string  address2;
    00405     pst_string  address2a;
    00407     pst_string  address2_desc;
    00409     pst_string  address2_transport;
    00411     pst_string  address3;
    00413     pst_string  address3a;
    00415     pst_string  address3_desc;
    00417     pst_string  address3_transport;
    00419     pst_string  assistant_name;
    00421     pst_string  assistant_phone;
    00423     pst_string  billing_information;
    00425     FILETIME   *birthday;
    00427     pst_string  business_address;
    00429     pst_string  business_city;
    00431     pst_string  business_country;
    00433     pst_string  business_fax;
    00435     pst_string  business_homepage;
    00437     pst_string  business_phone;
    00439     pst_string  business_phone2;
    00441     pst_string  business_po_box;
    00443     pst_string  business_postal_code;
    00445     pst_string  business_state;
    00447     pst_string  business_street;
    00449     pst_string  callback_phone;
    00451     pst_string  car_phone;
    00453     pst_string  company_main_phone;
    00455     pst_string  company_name;
    00457     pst_string  computer_name;
    00459     pst_string  customer_id;
    00461     pst_string  def_postal_address;
    00463     pst_string  department;
    00465     pst_string  display_name_prefix;
    00467     pst_string  first_name;
    00469     pst_string  followup;
    00471     pst_string  free_busy_address;
    00473     pst_string  ftp_site;
    00475     pst_string  fullname;
    00480     int16_t     gender;
    00482     pst_string  gov_id;
    00484     pst_string  hobbies;
    00486     pst_string  home_address;
    00488     pst_string  home_city;
    00490     pst_string  home_country;
    00492     pst_string  home_fax;
    00494     pst_string  home_phone;
    00496     pst_string  home_phone2;
    00498     pst_string  home_po_box;
    00500     pst_string  home_postal_code;
    00502     pst_string  home_state;
    00504     pst_string  home_street;
    00506     pst_string  initials;
    00508     pst_string  isdn_phone;
    00510     pst_string  job_title;
    00512     pst_string  keyword;
    00514     pst_string  language;
    00516     pst_string  location;
    00520     int         mail_permission;
    00522     pst_string  manager_name;
    00524     pst_string  middle_name;
    00526     pst_string  mileage;
    00528     pst_string  mobile_phone;
    00530     pst_string  nickname;
    00532     pst_string  office_loc;
    00534     pst_string  common_name;
    00536     pst_string  org_id;
    00538     pst_string  other_address;
    00540     pst_string  other_city;
    00542     pst_string  other_country;
    00544     pst_string  other_phone;
    00546     pst_string  other_po_box;
    00548     pst_string  other_postal_code;
    00550     pst_string  other_state;
    00552     pst_string  other_street;
    00554     pst_string  pager_phone;
    00556     pst_string  personal_homepage;
    00558     pst_string  pref_name;
    00560     pst_string  primary_fax;
    00562     pst_string  primary_phone;
    00564     pst_string  profession;
    00566     pst_string  radio_phone;
    00570     int         rich_text;
    00572     pst_string  spouse_name;
    00574     pst_string  suffix;
    00576     pst_string  surname;
    00578     pst_string  telex;
    00580     pst_string  transmittable_display_name;
    00582     pst_string  ttytdd_phone;
    00584     FILETIME   *wedding_anniversary;
    00586     pst_string  work_address_street;
    00588     pst_string  work_address_city;
    00590     pst_string  work_address_state;
    00592     pst_string  work_address_postalcode;
    00594     pst_string  work_address_country;
    00596     pst_string  work_address_postofficebox;
    00597 } pst_item_contact;
    00598
    00599
    00602 typedef struct pst_item_attach {
    00604     pst_string      filename1;
    00606     pst_string      filename2;
    00608     pst_string      mimetype;
    00610     pst_string      content_id;
    00612     pst_binary      data;
    00614     uint64_t        id2_val;
    00616     uint64_t        i_id;
    00618     pst_id2_tree    *id2_head;
    00627     int32_t         method;
    00629     int32_t         position;
    00631     int32_t         sequence;
    00632     struct pst_item_attach *next;
    00633 } pst_item_attach;
    00634
    00635
    00637 typedef struct pst_item_extra_field {
    00638     char   *field_name;
    00639     char   *value;
    00640     struct pst_item_extra_field *next;
    00641 } pst_item_extra_field;
    00642
    00643
    00646 typedef struct pst_item_journal {
    00648     FILETIME   *start;
    00650     FILETIME   *end;
    00652     pst_string  type;
    00654     pst_string  description;
    00655 } pst_item_journal;
    00656
    00657
    00661 typedef struct pst_recurrence {
    00663     uint32_t    signature;
    00668     uint32_t    type;
    00675     uint32_t    sub_type;
    00677     uint32_t    parm1;
    00678     uint32_t    parm2;
    00679     uint32_t    parm3;
    00680     uint32_t    parm4;
    00681     uint32_t    parm5;
    00687     uint32_t    termination;
    00689     uint32_t    interval;
    00691     uint32_t    bydaymask;
    00693     uint32_t    dayofmonth;
    00695     uint32_t    monthofyear;
    00697     uint32_t    position;
    00699     uint32_t    count;
    00700     // there is more data, including the termination date,
    00701     // but we can get that from other mapi elements.
    00702 } pst_recurrence;
    00703
    00704
    00707 typedef struct pst_item_appointment {
    00709     FILETIME   *start;
    00711     FILETIME   *end;
    00713     pst_string  location;
    00717     int         alarm;
    00719     FILETIME   *reminder;
    00721     int32_t     alarm_minutes;
    00723     pst_string  alarm_filename;
    00725     pst_string  timezonestring;
    00731     int32_t     showas;
    00744     int32_t     label;
    00748     int         all_day;
    00752     int         is_recurring;
    00759     int32_t     recurrence_type;
    00761     pst_string  recurrence_description;
    00763     pst_binary  recurrence_data;
    00765     FILETIME   *recurrence_start;
    00767     FILETIME   *recurrence_end;
    00768 } pst_item_appointment;
    00769
    00770
    00774 typedef struct pst_item {
    00776     struct pst_file        *pf;
    00778     uint64_t               block_id;
    00780     pst_item_email         *email;
    00782     pst_item_folder        *folder;
    00784     pst_item_contact       *contact;
    00786     pst_item_attach        *attach;
    00788     pst_item_message_store *message_store;
    00790     pst_item_extra_field   *extra_fields;
    00792     pst_item_journal       *journal;
    00794     pst_item_appointment   *appointment;
    00805     int         type;
    00807     char       *ascii_type;
    00819     int32_t     flags;
    00821     pst_string  file_as;
    00823     pst_string  comment;
    00825     pst_string  body_charset;
    00827     pst_string  body;
    00829     pst_string  subject;
    00831     int32_t     internet_cpid;
    00833     int32_t     message_codepage;
    00835     int32_t     message_size;
    00837     pst_string  outlook_version;
    00839     pst_binary  record_key;
    00841     pst_binary  predecessor_change;
    00845     int         response_requested;
    00847     FILETIME   *create_date;
    00849     FILETIME   *modify_date;
    00853     int         private_member;
    00854 } pst_item;
    00855
    00856
    00865 typedef struct pst_x_attrib_ll {
    00869     uint32_t mytype;
    00871     uint32_t map;
    00873     void     *data;
    00875     struct pst_x_attrib_ll *next;
    00876 } pst_x_attrib_ll;
    00877
    00878
    00880 typedef struct pst_block_recorder {
    00881     struct pst_block_recorder  *next;
    00882     int64_t                     offset;
    00883     size_t                      size;
    00884     int                         readcount;
    00885 } pst_block_recorder;
    00886
    00887
    00888 typedef struct pst_file {
    00890     FILE*   fp;
    00892     char*   cwd;
    00894     char*   fname;
    00896     const char*   charset;
    00898     pst_index_ll *i_head, *i_tail;
    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 // switch from maximal packing back to default packing
    01153 // undo the packing from the beginning of this file
    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