PST File Format SDK v0.4
Loading...
Searching...
No Matches
primitives.h
Go to the documentation of this file.
1
5
8
9#ifndef PSTSDK_UTIL_PRIMITIVES_H
10#define PSTSDK_UTIL_PRIMITIVES_H
11
12#include <boost/config.hpp>
13#include <boost/cstdint.hpp>
14#include <cstring>
15
16//
17// Global compiler hacks
18//
19
20#ifdef BOOST_NO_RVALUE_REFERENCES
21#ifndef SUPPRESS_CPLUSPLUS0X_MESSAGES
22#pragma message("C++0x rvalue references not supported; consider updating your compiler")
23#endif
24#endif
25
26#ifdef BOOST_NO_STATIC_ASSERT
27#include <boost/static_assert.hpp>
28#define static_assert(x,y) BOOST_STATIC_ASSERT(x)
29#endif
30
40#ifndef PSTSDK_VALIDATION_LEVEL_NONE
41#define PSTSDK_VALIDATION_LEVEL_WEAK
42#endif
43
44#ifdef PSTSDK_VALIDATION_LEVEL_FULL
45// full validation also implies weak validation
46#define PSTSDK_VALIDATION_LEVEL_WEAK
47#endif
48
49// Many of the low-level data structures in pstsdk rely on being laid out
50// in the fashion preferred by Visual C++. For example, these structures
51// need to align ulonglong to the nearest 8 bytes. Under GCC, we can force
52// this layout behavior on Mac and Linux systems by appending an
53// appropriate attribute declaration to the structure. We're also tried
54// '#pragma ms_struct on', but it fails on at least some Linux systems.
55#ifdef __GNUC__
56#define PSTSDK_MS_STRUCT __attribute__((ms_struct))
57#else
58#define PSTSDK_MS_STRUCT
59#endif
60
61namespace pstsdk
62{
63
67typedef boost::uint32_t uint;
68typedef boost::uint32_t ulong;
69typedef boost::int32_t slong;
70typedef boost::uint64_t ulonglong;
71typedef boost::int64_t slonglong;
72typedef boost::uint8_t byte;
73typedef boost::uint16_t ushort;
77static_assert(sizeof(byte) == 1, "pstsdk::byte unexpected size");
78static_assert(sizeof(ushort) == 2, "pstsdk::ushort unexpected size");
79static_assert(sizeof(uint) == 4, "pstsdk::uint unexpected size");
80static_assert(sizeof(ulonglong) == 8, "pstsdk::ulonglong unexpected size");
82
86typedef ulong node_id;
89
90typedef ulong heap_id;
92
94
95typedef ulong row_id;
110struct alias_tag { };
111
112//
113// node id
114//
115
151
155const ulong nid_type_mask = 0x1FL;
156
160#define make_nid(nid_type,nid_index) (((nid_type)&nid_type_mask)|((nid_index) << 5))
161
164#define make_prv_pub_nid(nid_index) (make_nid(nid_type_folder, nid_index_prv_pub_base + (nid_index)))
165
170{
217
224 { return (nid_type)(id & nid_type_mask); }
225
232 { return id >> 5; }
233
234//
235// heap id
236//
237
244 { return (id >> 16); }
245
252 { return (((id >> 5) - 1) & 0x7FF); }
253
260 { return (heap_id)((page << 16) | ((index + 1) << 5)); }
261
262//
263// heapnode id
264//
265
272inline bool is_heap_id(heapnode_id id)
273 { return (get_nid_type(id) == nid_type_none); }
274
282 { return (get_nid_type(id) != nid_type_none); }
283
284//
285// properties
286//
287
323
324//
325// mapi recipient type
326//
327
336
337//
338// message specific values
339//
340
345
346//
347// Win32 GUID
348//
349
359
360inline bool guid_eq(const guid &l, const guid &r) {
361 auto small_parts = l.data1 == r.data1 && l.data2 == r.data2 && l.data3 == r.data3;
362 if (!small_parts) return small_parts;
363 return small_parts && !std::memcmp(&l.data4, &r.data4, 8);
364}
365
367static_assert(sizeof(guid) == 16, "guid incorrect size");
369
372const guid ps_none = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
373
377const guid ps_mapi = { 0x20328, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
378
382const guid ps_public_strings = { 0x20329, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
383
385const guid ps_appointment = {0x62002, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
386
388const guid ps_task = {0x62003, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
389
391const guid ps_common = {0x62008, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
392
394const guid ps_address = {0x62004, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
395
397const guid ps_meeting = {0x6ED8DA90, 0x450B, 0x101B, { 0x98, 0xDA, 0x00, 0xAA, 0x00, 0x3F, 0x13, 0x05 } };
398
400const guid ps_internet_headers = {0x20386, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
401
403const guid ps_sharing = {0x62040, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
404
406const guid ps_log = {0x6200A, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
407
409const guid ps_postrss = {0x62041, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
410
412const guid ps_note = {0x6200E, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
413
415const guid ps_calendarassistant = {0x11000E07, 0xB51B, 0x40D6, { 0xAF, 0x21, 0xCA, 0xA8, 0x5E, 0xDA, 0xB1, 0xD0 } };
416
418const guid ps_remote = {0x62014, 0, 0, { 0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
419
422const guid provider_uid_wrapped_entry_id = {0xD3AD91C0, 0x9D51, 0x11CF, { 0xA4, 0xA9, 0x00, 0xAA, 0x00, 0x47, 0xFA, 0xA4 } };
423
427const guid provider_uid_recipient_oneoff = {0xA41F2B81, 0xA3BE, 0x1910, { 0x9D, 0x6E, 0x00, 0xDD, 0x01, 0x0F, 0x54, 0x02 } };
428
429} // end pstsdk namespace
430#endif
Contains references to other bth_node allocations.
Definition heap.h:364
Generic base class for all page typesA page which forms a node in the NBT or BBT.
Definition page.h:52
ulong get_heap_page(heap_id id)
Get the heap page from the heap id.
Definition primitives.h:243
const byte message_subject_prefix_lead_byte
A sentinel byte which indicates the message subject contains a prefix.
Definition primitives.h:344
boost::uint64_t ulonglong
Definition primitives.h:70
ulong get_nid_index(node_id id)
Get a node index from a node id.
Definition primitives.h:231
boost::uint8_t byte
Definition primitives.h:72
recipient_type
The different recipient types as defined by MAPI.
Definition primitives.h:331
nid_type
Different node types found in a PST file.
Definition primitives.h:120
boost::uint32_t uint
Definition primitives.h:67
nid_type get_nid_type(node_id id)
Get a node type from a node id.
Definition primitives.h:223
ulong row_id
Definition primitives.h:95
ulong node_id
Definition primitives.h:86
boost::int32_t slong
Definition primitives.h:69
boost::int64_t slonglong
Definition primitives.h:71
boost::uint32_t ulong
Definition primitives.h:68
#define make_prv_pub_nid(nid_index)
Construct a folders node_id for an OST file.
Definition primitives.h:164
block_id page_id
Definition primitives.h:88
#define make_nid(nid_type, nid_index)
Construct a node_id (NID) from a node type and index.
Definition primitives.h:160
ulong heap_id
Definition primitives.h:90
heap_id make_heap_id(ulong page, ulong index)
Create a heap_id from a page and an index.
Definition primitives.h:259
predefined_nid
The predefined nodes in a PST/OST file.
Definition primitives.h:170
ulonglong block_id
Definition primitives.h:87
const guid ps_public_strings
The PS_PUBLIC_STRINGS guid.
Definition primitives.h:382
ulong get_heap_index(heap_id id)
Get the index from the heap id.
Definition primitives.h:251
ulong heapnode_id
Definition primitives.h:91
const guid ps_none
The NULL guid.
Definition primitives.h:372
boost::uint16_t ushort
Definition primitives.h:73
const ulong nid_type_mask
The portion of a node_id reserved for the type.
Definition primitives.h:155
bool is_heap_id(heapnode_id id)
Inspects a heapnode_id (also known as a HNID) to determine if it is a heap_id (HID)
Definition primitives.h:272
ushort prop_id
Definition primitives.h:93
const guid ps_mapi
The PS_MAPI guid.
Definition primitives.h:377
bool is_subnode_id(heapnode_id id)
Inspects a heapnode_id (also known as a HNID) to determine if it is a node_id (NID)
Definition primitives.h:281
prop_type
The different property types as defined by MAPI.
Definition primitives.h:292
@ nid_type_hierarchy_table
Definition primitives.h:134
@ nid_type_contents_smp
Definition primitives.h:141
@ nid_type_contents_table
Definition primitives.h:135
@ nid_type_folder_path_tombstone_table
Definition primitives.h:147
@ nid_type_attachment
Definition primitives.h:126
@ nid_type_contents_table_index
Definition primitives.h:131
@ nid_type_max
Definition primitives.h:149
@ nid_type_ltp
Definition primitives.h:148
@ nid_type_search_contents_table
Definition primitives.h:137
@ nid_type_tombstone_table
Definition primitives.h:144
@ nid_type_none
Definition primitives.h:121
@ nid_type_storage
Definition primitives.h:130
@ nid_type_change_history_table
Definition primitives.h:143
@ nid_type_associated_contents_table
Definition primitives.h:136
@ nid_type_lrep_dups_table
Definition primitives.h:146
@ nid_type_search_folder
Definition primitives.h:124
@ nid_type_recipient_table
Definition primitives.h:139
@ nid_type_attachment_table
Definition primitives.h:138
@ nid_type_receive_folder_table
Definition primitives.h:132
@ nid_type_folder
Definition primitives.h:123
@ nid_type_internal
Definition primitives.h:122
@ nid_type_message
Definition primitives.h:125
@ nid_type_search_table_index
Definition primitives.h:140
@ nid_type_associated_contents_smp
Definition primitives.h:142
@ nid_type_search_update_queue
Definition primitives.h:127
@ nid_type_tombstone_date_table
Definition primitives.h:145
@ nid_type_outgoing_queue_table
Definition primitives.h:133
@ nid_type_search_criteria_object
Definition primitives.h:128
@ nid_type_associated_message
Definition primitives.h:129
@ nid_search_management_queue
Definition primitives.h:176
@ nid_index_template
Definition primitives.h:186
@ nid_search_gatherer_descriptor
Definition primitives.h:181
@ nid_tombstone_date_table
Definition primitives.h:200
@ nid_search_folder_template
Definition primitives.h:174
@ nid_tombstone_table
Definition primitives.h:199
@ nid_all_message_search_folder
Definition primitives.h:201
@ nid_recipient_table
Definition primitives.h:197
@ nid_search_domain_object
Definition primitives.h:179
@ nid_folder_path_tombstone_table
Definition primitives.h:206
@ nid_receive_folders
Definition primitives.h:194
@ nid_extended_notification
Definition primitives.h:214
@ nid_pub_root_folder
Definition primitives.h:209
@ nid_normal_folder_template
Definition primitives.h:173
@ nid_lrep_dups_table_template
Definition primitives.h:193
@ nid_search_domain_alternative
Definition primitives.h:178
@ nid_hst_hmp
Definition primitives.h:207
@ nid_newemail_notification
Definition primitives.h:213
@ nid_lrep_folders_table
Definition primitives.h:205
@ nid_outgoing_queue
Definition primitives.h:195
@ nid_indexing_notification
Definition primitives.h:215
@ nid_search_contents_table_template
Definition primitives.h:190
@ nid_object_notification
Definition primitives.h:212
@ nid_message_store
The property bag for this file.
Definition primitives.h:171
@ nid_search_gatherer_folder_queue
Definition primitives.h:184
@ nid_search_activity_list
Definition primitives.h:177
@ nid_prv_root_folder
Definition primitives.h:210
@ nid_lrep_folders_smp
Definition primitives.h:204
@ nid_name_id_map
Contains the named prop mappings.
Definition primitives.h:172
@ nid_lrep_gmp
Definition primitives.h:203
@ nid_table_rebuild_queue
Definition primitives.h:182
@ nid_junk_mail_pihsl
Definition primitives.h:183
@ nid_associated_contents_table_template
Definition primitives.h:189
@ nid_criterr_notification
Definition primitives.h:211
@ nid_root_folder
Root folder of the store.
Definition primitives.h:175
@ nid_search_gatherer_queue
Definition primitives.h:180
@ nid_change_history_table
Definition primitives.h:198
@ nid_tc_sub_props
Definition primitives.h:185
@ nid_all_message_search_contents
Definition primitives.h:202
@ nid_hierarchy_table_template
Definition primitives.h:187
@ nid_contents_table_template
Definition primitives.h:188
@ nid_index_prv_pub_base
Definition primitives.h:208
@ nid_smp_template
Definition primitives.h:191
@ nid_tombstone_table_template
Definition primitives.h:192
@ nid_attachment_table
Definition primitives.h:196
@ prop_type_object
Definition primitives.h:309
@ prop_type_mv_long
Definition primitives.h:298
@ prop_type_unspecified
Definition primitives.h:293
@ prop_type_currency
Definition primitives.h:303
@ prop_type_mv_string
Definition primitives.h:313
@ prop_type_boolean
Definition primitives.h:308
@ prop_type_mv_short
Definition primitives.h:296
@ prop_type_apptime
VT_DATE.
Definition primitives.h:305
@ prop_type_mv_systime
Definition primitives.h:317
@ prop_type_mv_currency
Definition primitives.h:304
@ prop_type_guid
Definition primitives.h:318
@ prop_type_binary
Definition primitives.h:320
@ prop_type_wstring
Definition primitives.h:314
@ prop_type_string
Definition primitives.h:312
@ prop_type_systime
Win32 FILETIME.
Definition primitives.h:316
@ prop_type_mv_apptime
Definition primitives.h:306
@ prop_type_longlong
Definition primitives.h:310
@ prop_type_mv_double
Definition primitives.h:302
@ prop_type_mv_longlong
Definition primitives.h:311
@ prop_type_float
Definition primitives.h:299
@ prop_type_error
Definition primitives.h:307
@ prop_type_long
Definition primitives.h:297
@ prop_type_mv_float
Definition primitives.h:300
@ prop_type_null
Definition primitives.h:294
@ prop_type_short
Definition primitives.h:295
@ prop_type_double
Definition primitives.h:301
@ prop_type_mv_guid
Definition primitives.h:319
@ prop_type_mv_wstring
Definition primitives.h:315
@ prop_type_mv_binary
Definition primitives.h:321
Contains the definition of all in memory representations of disk structures.
Definition disk.h:19
const guid ps_appointment
The PS_APPOINTMENT guid.
Definition primitives.h:385
const guid ps_calendarassistant
The PSETID_CalendarAssistant guid.
Definition primitives.h:415
const guid ps_common
The PS_COMMON guid.
Definition primitives.h:391
const guid ps_internet_headers
The PS_INTERNET_HEADERS guid.
Definition primitives.h:400
const guid ps_note
The PSETID_Note guid.
Definition primitives.h:412
const guid ps_address
The PSETID_Address guid.
Definition primitives.h:394
const guid ps_meeting
The PSETID_Meeting guid.
Definition primitives.h:397
const guid provider_uid_recipient_oneoff
The ProviderUID for Recipient One-Off EntryID.
Definition primitives.h:427
const guid ps_task
The PS_TASK guid.
Definition primitives.h:388
const guid ps_log
The PSETID_Log guid.
Definition primitives.h:406
const guid provider_uid_wrapped_entry_id
The ProviderUID for WrappedEntryId.
Definition primitives.h:422
const guid ps_remote
The PSETID_Remote guid.
Definition primitives.h:418
bool guid_eq(const guid &l, const guid &r)
Definition primitives.h:360
const guid ps_postrss
The PSETID_PostRss guid.
Definition primitives.h:409
const guid ps_sharing
The PSETID_Sharing guid.
Definition primitives.h:403
#define PSTSDK_MS_STRUCT
Definition primitives.h:58
Tag structure used to indicate a copy constructed class should be an alias (shallow copy) rather than...
Definition primitives.h:110
A Win32 GUID structure.
Definition primitives.h:353
byte data4[8]
Definition primitives.h:357