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

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 // 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
    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_index_ll {
    00092     uint64_t i_id;
    00093     uint64_t offset;
    00094     uint64_t size;
    00095     int64_t  u1;
    00096     struct pst_index_ll *next;
    00097 } pst_index_ll;
    00098
    00099
    00100 typedef struct pst_id2_tree {
    00101     uint64_t            id2;
    00102     pst_index_ll        *id;
    00103     struct pst_id2_tree *child;
    00104     struct pst_id2_tree *next;
    00105 } pst_id2_tree;
    00106
    00107
    00108 typedef struct pst_desc_tree {
    00109     uint64_t              d_id;
    00110     uint64_t              parent_d_id;
    00111     pst_index_ll         *desc;
    00112     pst_index_ll         *assoc_tree;
    00113     int32_t               no_child;
    00114     struct pst_desc_tree *prev;
    00115     struct pst_desc_tree *next;
    00116     struct pst_desc_tree *parent;
    00117     struct pst_desc_tree *child;
    00118     struct pst_desc_tree *child_tail;
    00119 } pst_desc_tree;
    00120
    00121
    00126 typedef struct pst_string {
    00129     int     is_utf8;
    00130     char   *str;
    00131 } pst_string;
    00132
    00133
    00135 typedef struct pst_binary {
    00136     size_t  size;
    00137     char   *data;
    00138 } pst_binary;
    00139
    00140
    00143 typedef struct pst_item_email {
    00145     FILETIME   *arrival_date;
    00150     int         autoforward;
    00152     pst_string  cc_address;
    00154     pst_string  bcc_address;
    00156     pst_binary  conversation_index;
    00160     int         conversion_prohibited;
    00164     int         delete_after_submit;
    00168     int         delivery_report;
    00170     pst_binary  encrypted_body;
    00172     pst_binary  encrypted_htmlbody;
    00174     pst_string  header;
    00176     pst_string  htmlbody;
    00181     int32_t     importance;
    00183     pst_string  in_reply_to;
    00187     int         message_cc_me;
    00191     int         message_recip_me;
    00195     int         message_to_me;
    00197     pst_string  messageid;
    00203     int32_t     original_sensitivity;
    00205     pst_string  original_bcc;
    00207     pst_string  original_cc;
    00209     pst_string  original_to;
    00211     pst_string  outlook_recipient;
    00213     pst_string  outlook_recipient_name;
    00215     pst_string  outlook_recipient2;
    00217     pst_string  outlook_sender;
    00219     pst_string  outlook_sender_name;
    00221     pst_string  outlook_sender2;
    00227     int32_t     priority;
    00229     pst_string  processed_subject;
    00233     int         read_receipt;
    00235     pst_string  recip_access;
    00237     pst_string  recip_address;
    00239     pst_string  recip2_access;
    00241     pst_string  recip2_address;
    00245     int         reply_requested;
    00247     pst_string  reply_to;
    00249     pst_string  return_path_address;
    00253     int32_t     rtf_body_char_count;
    00255     int32_t     rtf_body_crc;
    00259     pst_string  rtf_body_tag;
    00263     pst_binary  rtf_compressed;
    00271     int         rtf_in_sync;
    00274     int32_t     rtf_ws_prefix_count;
    00277     int32_t     rtf_ws_trailing_count;
    00279     pst_string  sender_access;
    00281     pst_string  sender_address;
    00283     pst_string  sender2_access;
    00285     pst_string  sender2_address;
    00291     int32_t     sensitivity;
    00293     FILETIME    *sent_date;
    00295     pst_entryid *sentmail_folder;
    00297     pst_string  sentto_address;
    00299     pst_string  report_text;
    00301     FILETIME   *report_time;
    00303     int32_t     ndr_reason_code;
    00305     int32_t     ndr_diag_code;
    00307     pst_string  supplementary_info;
    00309     int32_t     ndr_status_code;
    00310 } pst_item_email;
    00311
    00312
    00315 typedef struct pst_item_folder {
    00317     int32_t  item_count;
    00319     int32_t  unseen_item_count;
    00323     int32_t  assoc_count;
    00328     int      subfolder;
    00329 } pst_item_folder;
    00330
    00331
    00334 typedef struct pst_item_message_store {
    00336     pst_entryid *top_of_personal_folder;
    00338     pst_entryid *default_outbox_folder;
    00340     pst_entryid *deleted_items_folder;
    00342     pst_entryid *sent_items_folder;
    00344     pst_entryid *user_views_folder;
    00346     pst_entryid *common_view_folder;
    00348     pst_entryid *search_root_folder;
    00350     pst_entryid *top_of_folder;
    00361     int32_t valid_mask;
    00363     int32_t pwd_chksum;
    00364 } pst_item_message_store;
    00365
    00366
    00369 typedef struct pst_item_contact {
    00371     pst_string  account_name;
    00373     pst_string  address1;
    00375     pst_string  address1a;
    00377     pst_string  address1_desc;
    00379     pst_string  address1_transport;
    00381     pst_string  address2;
    00383     pst_string  address2a;
    00385     pst_string  address2_desc;
    00387     pst_string  address2_transport;
    00389     pst_string  address3;
    00391     pst_string  address3a;
    00393     pst_string  address3_desc;
    00395     pst_string  address3_transport;
    00397     pst_string  assistant_name;
    00399     pst_string  assistant_phone;
    00401     pst_string  billing_information;
    00403     FILETIME   *birthday;
    00405     pst_string  business_address;
    00407     pst_string  business_city;
    00409     pst_string  business_country;
    00411     pst_string  business_fax;
    00413     pst_string  business_homepage;
    00415     pst_string  business_phone;
    00417     pst_string  business_phone2;
    00419     pst_string  business_po_box;
    00421     pst_string  business_postal_code;
    00423     pst_string  business_state;
    00425     pst_string  business_street;
    00427     pst_string  callback_phone;
    00429     pst_string  car_phone;
    00431     pst_string  company_main_phone;
    00433     pst_string  company_name;
    00435     pst_string  computer_name;
    00437     pst_string  customer_id;
    00439     pst_string  def_postal_address;
    00441     pst_string  department;
    00443     pst_string  display_name_prefix;
    00445     pst_string  first_name;
    00447     pst_string  followup;
    00449     pst_string  free_busy_address;
    00451     pst_string  ftp_site;
    00453     pst_string  fullname;
    00458     int16_t     gender;
    00460     pst_string  gov_id;
    00462     pst_string  hobbies;
    00464     pst_string  home_address;
    00466     pst_string  home_city;
    00468     pst_string  home_country;
    00470     pst_string  home_fax;
    00472     pst_string  home_phone;
    00474     pst_string  home_phone2;
    00476     pst_string  home_po_box;
    00478     pst_string  home_postal_code;
    00480     pst_string  home_state;
    00482     pst_string  home_street;
    00484     pst_string  initials;
    00486     pst_string  isdn_phone;
    00488     pst_string  job_title;
    00490     pst_string  keyword;
    00492     pst_string  language;
    00494     pst_string  location;
    00498     int         mail_permission;
    00500     pst_string  manager_name;
    00502     pst_string  middle_name;
    00504     pst_string  mileage;
    00506     pst_string  mobile_phone;
    00508     pst_string  nickname;
    00510     pst_string  office_loc;
    00512     pst_string  common_name;
    00514     pst_string  org_id;
    00516     pst_string  other_address;
    00518     pst_string  other_city;
    00520     pst_string  other_country;
    00522     pst_string  other_phone;
    00524     pst_string  other_po_box;
    00526     pst_string  other_postal_code;
    00528     pst_string  other_state;
    00530     pst_string  other_street;
    00532     pst_string  pager_phone;
    00534     pst_string  personal_homepage;
    00536     pst_string  pref_name;
    00538     pst_string  primary_fax;
    00540     pst_string  primary_phone;
    00542     pst_string  profession;
    00544     pst_string  radio_phone;
    00548     int         rich_text;
    00550     pst_string  spouse_name;
    00552     pst_string  suffix;
    00554     pst_string  surname;
    00556     pst_string  telex;
    00558     pst_string  transmittable_display_name;
    00560     pst_string  ttytdd_phone;
    00562     FILETIME   *wedding_anniversary;
    00564     pst_string  work_address_street;
    00566     pst_string  work_address_city;
    00568     pst_string  work_address_state;
    00570     pst_string  work_address_postalcode;
    00572     pst_string  work_address_country;
    00574     pst_string  work_address_postofficebox;
    00575 } pst_item_contact;
    00576
    00577
    00580 typedef struct pst_item_attach {
    00582     pst_string      filename1;
    00584     pst_string      filename2;
    00586     pst_string      mimetype;
    00588     pst_binary      data;
    00590     uint64_t        id2_val;
    00592     uint64_t        i_id;
    00594     pst_id2_tree    *id2_head;
    00603     int32_t         method;
    00605     int32_t         position;
    00607     int32_t         sequence;
    00608     struct pst_item_attach *next;
    00609 } pst_item_attach;
    00610
    00611
    00613 typedef struct pst_item_extra_field {
    00614     char   *field_name;
    00615     char   *value;
    00616     struct pst_item_extra_field *next;
    00617 } pst_item_extra_field;
    00618
    00619
    00622 typedef struct pst_item_journal {
    00624     FILETIME   *start;
    00626     FILETIME   *end;
    00628     pst_string  type;
    00630     pst_string  description;
    00631 } pst_item_journal;
    00632
    00633
    00637 typedef struct pst_recurrence {
    00639     uint32_t    signature;
    00644     uint32_t    type;
    00651     uint32_t    sub_type;
    00653     uint32_t    parm1;
    00654     uint32_t    parm2;
    00655     uint32_t    parm3;
    00656     uint32_t    parm4;
    00657     uint32_t    parm5;
    00663     uint32_t    termination;
    00665     uint32_t    interval;
    00667     uint32_t    bydaymask;
    00669     uint32_t    dayofmonth;
    00671     uint32_t    monthofyear;
    00673     uint32_t    position;
    00675     uint32_t    count;
    00676     // there is more data, including the termination date,
    00677     // but we can get that from other mapi elements.
    00678 } pst_recurrence;
    00679
    00680
    00683 typedef struct pst_item_appointment {
    00685     FILETIME   *start;
    00687     FILETIME   *end;
    00689     pst_string  location;
    00693     int         alarm;
    00695     FILETIME   *reminder;
    00697     int32_t     alarm_minutes;
    00699     pst_string  alarm_filename;
    00701     pst_string  timezonestring;
    00707     int32_t     showas;
    00720     int32_t     label;
    00724     int         all_day;
    00728     int         is_recurring;
    00735     int32_t     recurrence_type;
    00737     pst_string  recurrence_description;
    00739     pst_binary  recurrence_data;
    00741     FILETIME   *recurrence_start;
    00743     FILETIME   *recurrence_end;
    00744 } pst_item_appointment;
    00745
    00746
    00750 typedef struct pst_item {
    00752     pst_item_email         *email;
    00754     pst_item_folder        *folder;
    00756     pst_item_contact       *contact;
    00758     pst_item_attach        *attach;
    00760     pst_item_message_store *message_store;
    00762     pst_item_extra_field   *extra_fields;
    00764     pst_item_journal       *journal;
    00766     pst_item_appointment   *appointment;
    00777     int         type;
    00779     char       *ascii_type;
    00791     int32_t     flags;
    00793     pst_string  file_as;
    00795     pst_string  comment;
    00797     pst_string  body_charset;
    00799     pst_string  body;
    00801     pst_string  subject;
    00803     int32_t     internet_cpid;
    00805     int32_t     message_codepage;
    00807     int32_t     message_size;
    00809     pst_string  outlook_version;
    00811     pst_binary  record_key;
    00813     pst_binary  predecessor_change;
    00817     int         response_requested;
    00819     FILETIME   *create_date;
    00821     FILETIME   *modify_date;
    00825     int         private_member;
    00826 } pst_item;
    00827
    00828
    00837 typedef struct pst_x_attrib_ll {
    00841     uint32_t mytype;
    00843     uint32_t map;
    00845     void     *data;
    00847     struct pst_x_attrib_ll *next;
    00848 } pst_x_attrib_ll;
    00849
    00850
    00852 typedef struct pst_block_recorder {
    00853     struct pst_block_recorder  *next;
    00854     int64_t                     offset;
    00855     size_t                      size;
    00856     int                         readcount;
    00857 } pst_block_recorder;
    00858
    00859
    00860 typedef struct pst_file {
    00862     FILE*   fp;
    00864     char*   cwd;
    00866     char*   fname;
    00868     pst_index_ll *i_head, *i_tail;
    00870     pst_desc_tree  *d_head, *d_tail;
    00872     pst_x_attrib_ll *x_head;
    00876     pst_block_recorder *block_head;
    00877
    00880     int do_read64;
    00882     uint64_t index1;
    00884     uint64_t index1_back;
    00886     uint64_t index2;
    00888     uint64_t index2_back;
    00890     uint64_t size;
    00894     unsigned char encryption;
    00900     unsigned char ind_type;
    00901 } pst_file;
    00902
    00903
    00910 int             pst_open(pst_file *pf, const char *name);
    00911
    00912
    00917 int             pst_reopen(pst_file *pf);
    00918
    00919
    00925 int             pst_load_index (pst_file *pf);
    00926
    00927
    00932 int             pst_load_extended_attributes(pst_file *pf);
    00933
    00934
    00938 int             pst_close(pst_file *pf);
    00939
    00940
    00946 pst_desc_tree*  pst_getTopOfFolders(pst_file *pf, const pst_item *root);
    00947
    00948
    00955 pst_binary      pst_attach_to_mem(pst_file *pf, pst_item_attach *attach);
    00956
    00957
    00963 size_t          pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp);
    00964
    00965
    00971 size_t          pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp);
    00972
    00973
    00978 pst_desc_tree*  pst_getNextDptr(pst_desc_tree* d);
    00979
    00980
    00988 pst_item*       pst_parse_item (pst_file *pf, pst_desc_tree *d_ptr, pst_id2_tree *m_head);
    00989
    00990
    00994 void            pst_freeItem(pst_item *item);
    00995
    00996
    01002 pst_index_ll*   pst_getID(pst_file* pf, uint64_t i_id);
    01003
    01004
    01012 size_t          pst_ff_getIDblock_dec(pst_file *pf, uint64_t i_id, char **buf);
    01013
    01014
    01022 size_t          pst_fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream);
    01023
    01024
    01033 char*           pst_rfc2426_escape(char* str, char** result, size_t* resultlen);
    01034
    01035
    01043 char*           pst_rfc2425_datetime_format(const FILETIME* ft, int buflen, char* result);
    01044
    01045
    01052 char*           pst_rfc2445_datetime_format(const FILETIME* ft, int buflen, char* result);
    01053
    01054
    01060 char*           pst_rfc2445_datetime_format_now(int buflen, char* result);
    01061
    01062
    01070 const char*     pst_default_charset(pst_item *item, int buflen, char* result);
    01071
    01072
    01077 void            pst_convert_utf8_null(pst_item *item, pst_string *str);
    01078
    01079
    01084 void            pst_convert_utf8(pst_item *item, pst_string *str);
    01085
    01086
    01091 pst_recurrence* pst_convert_recurrence(pst_item_appointment* appt);
    01092
    01093
    01097 void            pst_free_recurrence(pst_recurrence* r);
    01098
    01099
    01100
    01101 // switch from maximal packing back to default packing
    01102 // undo the packing from the beginning of this file
    01103 #ifdef _MSC_VER
    01104     #pragma pack(pop)
    01105 #endif
    01106 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC)
    01107     #pragma pack()
    01108 #endif
    01109
    01110
    01111
    01112 #endif