pst

package
v6.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 27 Imported by: 2

Documentation

Overview

Package pst implements reading Personal Storage Table (.pst) files.

Index

Constants

View Source
const LZFUHeader = "" /* 236-byte string literal not displayed */

Variables

View Source
var (
	ErrFileSignatureInvalid             = errors.New("go-pst: invalid file signature")
	ErrFormatTypeUnsupported            = errors.New("go-pst: unsupported format type")
	ErrEncryptionTypeUnsupported        = errors.New("go-pst: unsupported encryption type")
	ErrContentTypeUnsupported           = errors.New("go-pst: unsupported content type")
	ErrMessageIdentifierTypeInvalid     = errors.New("go-pst: invalid message identifier type")
	ErrPropertyNotFound                 = errors.New("go-pst: failed to find property by ID")
	ErrTableTypeInvalid                 = errors.New("go-pst: invalid table type")
	ErrBTreeNodeConflict                = errors.New("go-pst: conflicting b-tree node entry")
	ErrBTreeNodeNotFound                = errors.New("go-pst: failed to find b-tree node")
	ErrHeapOnNodeExternalNode           = errors.New("go-pst: external node, no local descriptors provided")
	ErrTableSignatureInvalid            = errors.New("go-pst: invalid table signature")
	ErrTableContextNoColumns            = errors.New("go-pst: there are no columns in this table context")
	ErrTableContextNoRows               = errors.New("go-pst: there are no rows in this table context")
	ErrBlockTypeInvalid                 = errors.New("go-pst: unsupported block type")
	ErrBlockSignatureInvalid            = errors.New("go-pst: invalid block signature")
	ErrAttachmentIndexInvalid           = errors.New("go-pst: invalid attachment index, there are no more attachments")
	ErrLocalDescriptorsSignatureInvalid = errors.New("go-pst: invalid local descriptors signature")
	ErrLocalDescriptorNotFound          = errors.New("go-pst: failed to find local descriptor")
	ErrLocalDescriptorBranchNode        = errors.New("go-pst: local descriptors level is not 0, please open an issue on GitHub for this to be implemented")
	ErrPropertyTypeMismatch             = errors.New("go-pst: property type is not the same as the value expected from the caller")
	ErrPropertyNoData                   = errors.New("go-pst: property has no data")
	ErrNameToIDMapKeyNotFound           = errors.New("go-pst: failed to find key in Name-To-ID Map")
	ErrMessagesNotFound                 = errors.New("go-pst: folder has no messages")
	ErrAttachmentsNotFound              = errors.New("go-pst: message has no attachments")
	ErrBlockIndexNotFound               = errors.New("go-pst: block index not found")
	ErrTotalBlocksSizeMismatch          = errors.New("go-pst: block total size mismatch")
)

Constants defining go-pst errors. We use stack-traces (Wrap) via https://github.com/rotisserie/eris

View Source
var (
	CompressionTypeCompressed   = []byte("LZFu")
	CompressionTypeUncompressed = []byte("MELA")
)
View Source
var CodePageIdentifierToEncoding = map[int]string{
	28596: "iso-8859-6",
	1256:  "windows-1256",
	28594: "iso-8859-4",
	1257:  "windows-1257",
	28592: "iso-8859-2",
	1250:  "windows-1250",
	936:   "gb2312",
	52936: "hz-gb-2312",
	54936: "gb18030",
	950:   "big5",
	28595: "iso-8859-5",
	20866: "koi8-r",
	21866: "koi8-u",
	1251:  "windows-1251",
	28597: "iso-8859-7",
	1253:  "windows-1253",
	38598: "iso-8859-8-i",
	1255:  "windows-1255",
	51932: "euc-jp",
	50220: "iso-2022-jp",
	50221: "csISO2022JP",
	932:   "iso-2022-jp",
	949:   "ks_c_5601-1987",
	51949: "euc-kr",
	28593: "iso-8859-3",
	28605: "iso-8859-15",
	874:   "windows-874",
	28599: "iso-8859-9",
	1254:  "windows-1254",
	65000: "utf-7",
	65001: "utf-8",
	20127: "us-ascii",
	1258:  "windows-1258",
	28591: "iso-8859-1",
	1252:  "Windows-1252",
}

CodePageIdentifierToEncoding maps the code page identifier to the IANA encoding for decoding String8 (PropertyReader). References https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers

View Source
var PropertyMap = make(map[string][]string)

PropertyMap maps the property ID to the struct tag and property set (if any).

View Source
var PropertyMapCSV string
View Source
var PropertySets = []string{
	"00020329-0000-0000-C000-000000000046",
	"00062008-0000-0000-C000-000000000046",
	"00062004-0000-0000-C000-000000000046",
	"00020386-0000-0000-C000-000000000046",
	"00062002-0000-0000-C000-000000000046",
	"6ED8DA90-450B-101B-98DA-00AA003F1305",
	"0006200A-0000-0000-C000-000000000046",
	"41F28F13-83F4-4114-A584-EEDB5A6B0BFF",
	"0006200E-0000-0000-C000-000000000046",
	"00062041-0000-0000-C000-000000000046",
	"00062003-0000-0000-C000-000000000046",
	"4442858E-A9E3-4E80-B900-317A210CC15B",
	"00020328-0000-0000-C000-000000000046",
	"71035549-0739-4DCB-9163-00F0580DBBDF",
	"00062040-0000-0000-C000-000000000046",
	"23239608-685D-4732-9C55-4C95CB4E8E33",
	"96357F7F-59E1-47D0-99A7-46515C183B54",
}

PropertySets defines the property sets (GUIDs) in the Name-To-ID Map. "Property set: A GUID that identifies a group of properties with a similar purpose." References [MS-OXPROPS]: "1.3.2 Commonly Used Property Sets".

Functions

func BTreeNodeLessFunc

func BTreeNodeLessFunc(a BTreeNode, b BTreeNode) bool

BTreeNodeLessFunc tests whether the current node is less than the given argument.

This must provide a strict weak ordering. If !a.Less(b) && !b.Less(a), we treat this to mean a == b (we can only hold one of either a or b in the tree).

func DecodeString

func DecodeString(s string) (string, error)

DecodeString decodes an internationalized string. If it fails, it returns the input string and the error.

func ExtendCharsets

func ExtendCharsets(registerFunc func(name string, enc encoding.Encoding))

func GetBTreeNodeEntryFileOffset

func GetBTreeNodeEntryFileOffset(btreeNodeEntryData []byte, isBranchNode bool, formatType FormatType) int64

GetBTreeNodeEntryFileOffset returns the file offset for this b-tree branch or leaf node. References "The b-tree entries".

func GetBTreeNodeEntrySize

func GetBTreeNodeEntrySize(btreeNodeEntryData []byte, formatType FormatType) uint16

GetBTreeNodeEntrySize returns the size of the data in the block b-tree leaf node entry. References "The b-tree entries".

func GetIdentifierSize

func GetIdentifierSize(formatType FormatType) uint8

GetIdentifierSize returns the size of an Identifier.

func NewBTreeNodeReader

func NewBTreeNodeReader(btreeNode BTreeNode, reader Reader) *io.SectionReader

NewBTreeNodeReader is used by the Heap-on-Node.

func NewBTreeStoreInMemory

func NewBTreeStoreInMemory() *btree.BTreeG[BTreeNode]

NewBTreeStoreInMemory creates a new b-tree store using google/btree.

Types

type AsyncReader

type AsyncReader struct {
	// contains filtered or unexported fields
}

func NewReaderAsync

func NewReaderAsync(name string) (*AsyncReader, error)

NewReaderAsync uses io_uring on Linux for asynchronous I/O operations.

func (*AsyncReader) Close

func (asyncReader *AsyncReader) Close()

Close closes the event loop.

func (*AsyncReader) ReadAt

func (asyncReader *AsyncReader) ReadAt(outputBuffer []byte, offset int64) (int, error)

ReadAt is a fall-back for where we haven't added async disk I/O support yet.

func (*AsyncReader) ReadAtAsync

func (asyncReader *AsyncReader) ReadAtAsync(outputBuffer []byte, offset uint64, callback func(err error)) (uint64, error)

ReadAtAsync io_uring operation. The callback function is called when a CQE is received. Returns uint64 which can be used as the SQE identifier.

type Attachment

type Attachment struct {
	Identifier       Identifier
	PropertyContext  *PropertyContext
	LocalDescriptors []LocalDescriptor
	properties.Attachment
}

Attachment represents a message attachment.

func (*Attachment) WriteTo

func (attachment *Attachment) WriteTo(writer io.Writer) (int64, error)

WriteTo writes the attachment to the specified io.Writer.

type AttachmentIterator

type AttachmentIterator struct {
	// contains filtered or unexported fields
}

AttachmentIterator implements an attachment iterator.

func (*AttachmentIterator) CurrentIndex

func (attachmentIterator *AttachmentIterator) CurrentIndex() int

func (*AttachmentIterator) Err

func (attachmentIterator *AttachmentIterator) Err() error

Err return the error cause.

func (*AttachmentIterator) Next

func (attachmentIterator *AttachmentIterator) Next() bool

Next will ensure that Value returns the next item when executed. If the next value is not retrievable, Next will return false and Err() will return the error cause.

func (*AttachmentIterator) Size

func (attachmentIterator *AttachmentIterator) Size() int

Size returns the amount of attachments in the message iterator.

func (*AttachmentIterator) Value

func (attachmentIterator *AttachmentIterator) Value() *Attachment

Value returns the current value in the iterator.

type BTreeNode

type BTreeNode struct {
	// Identifier is only unique to the node level.
	Identifier                 Identifier `json:"identifier"`
	FileOffset                 int64      `json:"fileOffset"`
	DataIdentifier             Identifier `json:"dataIdentifier"`
	LocalDescriptorsIdentifier Identifier `json:"localDescriptorsIdentifier"`
	Size                       uint16     `json:"size"`
	NodeLevel                  uint8      `json:"nodeLevel"`
}

BTreeNode represents an entry in a b-tree node.

type BTreeOnHeapHeader

type BTreeOnHeapHeader struct {
	TableType uint8
	KeySize   uint8
	ValueSize uint8
	Levels    uint8
	HIDRoot   Identifier
}

BTreeOnHeapHeader represents the B-Tree-on-Heap header.

type BTreeStore

type BTreeStore interface {
	// Load adds the b-tree nodes to the b-tree store.
	Load(node BTreeNode) (BTreeNode, bool)
	Get(key BTreeNode) (BTreeNode, bool)
	Len() int
	Clear()
}

BTreeStore is an abstraction used to store the node and block b-tree. This is useful if you want to persist the b-tree to disk for example. An initialized b-tree store can be passed to pst.NewFromReaderWithBTrees.

This interface defines the functions we use from tidwall/btree.

type BTreeType

type BTreeType uint8

BTreeType represents either the node b-tree or block b-tree.

const (
	BTreeTypeNode BTreeType = iota
	BTreeTypeBlock
)

Constants defining the b-tree types.

type BlockType

type BlockType uint8

BlockType represents a XBlock or XXBlock.

const (
	BlockTypeXBlock  BlockType = 1
	BlockTypeXXBlock BlockType = 2
)

Constants defining the block types.

type ColumnDescriptor

type ColumnDescriptor struct {
	PropertyType             PropertyType
	PropertyID               uint16
	DataOffset               uint16
	DataSize                 uint8
	CellExistenceBitmapIndex uint8
}

ColumnDescriptor represents a column in the Table Context. References "Table Context", "Table Context Column Descriptor".

func NewColumnDescriptor

func NewColumnDescriptor(tableContextReader io.ReaderAt, columnStartOffset int64) (ColumnDescriptor, error)

NewColumnDescriptor is a constructor for creating column descriptors.

type ContentType

type ContentType uint8

ContentType represents a PST, OST or PAB file.

const (
	ContentTypePST ContentType = iota
	ContentTypeOST
	ContentTypePAB
)

Constants defining the content types. References "Content Types".

type DefaultReader

type DefaultReader struct {
	// contains filtered or unexported fields
}

DefaultReader implements Reader using io.ReaderAt.

func NewDefaultReader

func NewDefaultReader(reader io.ReaderAt) *DefaultReader

func (*DefaultReader) ReadAt

func (defaultReader *DefaultReader) ReadAt(outputBuffer []byte, offset int64) (int, error)

ReadAt calls the underlying io.ReaderAt.

func (*DefaultReader) ReadAtAsync

func (defaultReader *DefaultReader) ReadAtAsync(outputBuffer []byte, offset uint64, callback func(err error)) (uint64, error)

ReadAtAsync is a fall-back which calls io.ReaderAt. See AsyncReader for Linux io_uring support.

type EncryptionType

type EncryptionType uint8
const (
	EncryptionTypeNone    EncryptionType = 0
	EncryptionTypePermute EncryptionType = 1
)

Constants defining the encryption types. References "Encryption Types".

type File

type File struct {
	Reader         Reader
	FormatType     FormatType
	EncryptionType EncryptionType
	NodeBTree      BTreeStore
	BlockBTree     BTreeStore
	NameToIDMap    *NameToIDMap
}

File represents a PST file.

func New

func New(reader io.ReaderAt) (*File, error)

New is a constructor for creating PST files. See also NewAsync.

func NewAsync

func NewAsync(name string) (*File, error)

NewAsync uses io_uring on Linux.

func NewFromReaderWithBTrees

func NewFromReaderWithBTrees(reader Reader, nodeBTree BTreeStore, blockBTree BTreeStore) (*File, error)

NewFromReaderWithBTrees is a constructor for creating PST files from a reader using the specified b-tree stores. Initialization of the b-tree stores will be skipped respectively if not empty.

func (*File) Cleanup

func (file *File) Cleanup()

Cleanup clears the node and block b-trees.

func (*File) GetAttachment added in v6.0.2

func (file *File) GetAttachment(messageIdentifier Identifier) (*Attachment, error)

GetAttachment returns the attachment. Note that the properties aren't populated (call PropertyContext.Populate).

func (*File) GetBTreeNode

func (file *File) GetBTreeNode(identifier Identifier, btreeStore BTreeStore) (BTreeNode, error)

GetBTreeNode returns the node in the node or block b-tree with the given identifier.

func (*File) GetBTreeNodeEntries

func (file *File) GetBTreeNodeEntries(btreeNodeOffset int64, btreeType BTreeType, callback func(btreeNodeEntries []BTreeNode, nodeLevel uint8, err error))

GetBTreeNodeEntries returns the entries in the b-tree node.

func (*File) GetBTreeNodeEntryCount

func (file *File) GetBTreeNodeEntryCount(btreeNode []byte) uint16

GetBTreeNodeEntryCount returns the amount of entries in the b-tree.

func (*File) GetBTreeNodeEntrySize

func (file *File) GetBTreeNodeEntrySize(btreeNode []byte) uint8

GetBTreeNodeEntrySize returns the size of an entry in the b-tree.

func (*File) GetBTreeNodeLevel

func (file *File) GetBTreeNodeLevel(btreeNode []byte) uint8

GetBTreeNodeLevel returns the level of the b-tree node. References "The node and block b-tree".

func (*File) GetBTreeNodeRawEntries

func (file *File) GetBTreeNodeRawEntries(btreeNodeOffset int64, callback func([]byte, error))

GetBTreeNodeRawEntries returns the raw b-tree node entries in bytes. References https://github.com/mooijtech/go-pst/blob/master/docs/README.md#btpage Used by GetBTreeNodeEntries.

func (*File) GetBTreeOnHeapHeader

func (file *File) GetBTreeOnHeapHeader(heapOnNode *HeapOnNode) (*BTreeOnHeapHeader, error)

GetBTreeOnHeapHeader returns the B-Tree-on-Heap header.

func (*File) GetBlockBTreeNode

func (file *File) GetBlockBTreeNode(identifier Identifier) (BTreeNode, error)

GetBlockBTreeNode returns the node with the given identifier in the block b-tree.

func (*File) GetBlockBTreeOffset

func (file *File) GetBlockBTreeOffset() (int64, error)

GetBlockBTreeOffset returns the file offset to the block b-tree.

func (*File) GetBlockSize

func (file *File) GetBlockSize() (int, error)

GetBlockSize returns the size of a block. References "Blocks".

func (*File) GetBlockTrailerSize

func (file *File) GetBlockTrailerSize() (int, error)

GetBlockTrailerSize returns the size of a block trailer. References "Blocks".

func (*File) GetBlocks

func (file *File) GetBlocks(btreeNodeHeapOnNodeOffset int64) ([]BTreeNode, error)

GetBlocks returns all blocks (XBlock/XXBlock) from a Heap-on-Node along with the total blocks size. Internal identifiers have blocks.

References: - https://github.com/mooijtech/go-pst/tree/master/docs#xblock - https://github.com/mooijtech/go-pst/tree/master/docs#xxblock

func (*File) GetBlocksTotalSize

func (file *File) GetBlocksTotalSize(nodeEntryHeapOnNodeOffset int64) (uint32, error)

GetBlocksTotalSize returns the size of the external data referenced by the XBlock or XXBlock.

func (*File) GetContentType

func (file *File) GetContentType() (ContentType, error)

GetContentType returns if the file is a PST, OST or PAB file. References "File Header", "Content Types".

func (*File) GetDataBTreeNode

func (file *File) GetDataBTreeNode(identifier Identifier) (BTreeNode, error)

GetDataBTreeNode searches the identifier in the node b-tree, then searches the data identifier in the block b-tree.

func (*File) GetEncryptionType

func (file *File) GetEncryptionType() (EncryptionType, error)

GetEncryptionType returns the encryption type. References "The 64-bit header data", "The 32-bit header data", "Encryption Types".

func (*File) GetFormatType

func (file *File) GetFormatType() (FormatType, error)

GetFormatType returns the format type. References "File Header", "Format Types".

func (*File) GetHeapOnNode

func (file *File) GetHeapOnNode(btreeNode BTreeNode) (*HeapOnNode, error)

GetHeapOnNode returns the Heap-on-Node of the b-tree node.

func (*File) GetHeapOnNodeFromLocalDescriptor

func (file *File) GetHeapOnNodeFromLocalDescriptor(localDescriptor LocalDescriptor) (*HeapOnNode, error)

GetHeapOnNodeFromLocalDescriptor creates a Heap-on-Node from the local descriptor.

func (*File) GetHeapOnNodeReaderFromHID

func (file *File) GetHeapOnNodeReaderFromHID(hid Identifier, heapOnNodeReader HeapOnNodeReader) (*HeapOnNodeReader, error)

GetHeapOnNodeReaderFromHID returns the Heap-on-Node reader from the heap ID.

func (*File) GetHeapOnNodeReaderFromHNID

func (file *File) GetHeapOnNodeReaderFromHNID(hnid Identifier, heapOnNodeReader HeapOnNodeReader, localDescriptors ...LocalDescriptor) (*HeapOnNodeReader, error)

GetHeapOnNodeReaderFromHNID returns the Heap-on-Node reader from the specified HNID (heap or node identifier). Note this doesn't keep track of all the passed HeapOnNodeReader blocks.

func (*File) GetLocalDescriptors

func (file *File) GetLocalDescriptors(btreeNodeEntry BTreeNode) ([]LocalDescriptor, error)

GetLocalDescriptors returns the local descriptors of the b-tree node.

func (*File) GetLocalDescriptorsFromIdentifier

func (file *File) GetLocalDescriptorsFromIdentifier(localDescriptorsIdentifier Identifier) ([]LocalDescriptor, error)

GetLocalDescriptorsFromIdentifier returns the local descriptors of the local descriptors identifier. References "Local Descriptors".

func (*File) GetMessage

func (file *File) GetMessage(identifier Identifier) (*Message, error)

GetMessage returns the message of the identifier.

func (*File) GetMessageStore

func (file *File) GetMessageStore() (*PropertyContext, error)

GetMessageStore returns the message store of the PST file.

func (*File) GetNameToIDMap

func (file *File) GetNameToIDMap() (*NameToIDMap, error)

GetNameToIDMap returns the Name-To-ID Map.

func (*File) GetNodeBTreeNode

func (file *File) GetNodeBTreeNode(identifier Identifier) (BTreeNode, error)

GetNodeBTreeNode returns the node with the given identifier in the node b-tree.

func (*File) GetNodeBTreeOffset

func (file *File) GetNodeBTreeOffset() (int64, error)

GetNodeBTreeOffset returns the file offset to the node b-tree.

func (*File) GetParentBTreeNodeLevel

func (file *File) GetParentBTreeNodeLevel(btreeNodeOffset int64) (uint8, error)

GetParentBTreeNodeLevel returns the level of the b-tree node. References "The node and block b-tree".

func (*File) GetPropertyContext

func (file *File) GetPropertyContext(heapOnNode *HeapOnNode) (*PropertyContext, error)

GetPropertyContext returns the property context (BC Table). References https://github.com/mooijtech/go-pst/tree/master/docs#property-context-pc

func (*File) GetRootFolder

func (file *File) GetRootFolder() (Folder, error)

GetRootFolder returns the root folder of the PST file.

func (*File) GetTableContext

func (file *File) GetTableContext(heapOnNode *HeapOnNode, localDescriptors []LocalDescriptor, propertyIDsToGet ...uint16) (TableContext, error)

GetTableContext returns the table context. If propertyIDsToGet is empty all properties will be returned. References "Table Context".

func (*File) GetTableContextProperty

func (file *File) GetTableContextProperty(tableRowMatrixReader io.ReaderAt, rowOffset int64, column ColumnDescriptor) (Property, error)

GetTableContextProperty is used by GetTableContext to only returns certain columns. References [MS-PDF]: 2.3.4.4.1 Row Data Format

func (*File) IsValidSignature

func (file *File) IsValidSignature() (bool, error)

IsValidSignature returns true is the file matches the PFF format signature. References "File Header".

func (*File) WalkAndCreateBTree

func (file *File) WalkAndCreateBTree(btreeOffset int64, btreeType BTreeType, btreeStore BTreeStore)

WalkAndCreateBTree walks the b-tree and updates the given b-tree store.

func (*File) WalkFolders

func (file *File) WalkFolders(walkFolderFunc WalkFolderFunc) error

WalkFolders walks all folders recursively.

type Folder

type Folder struct {
	Identifier      Identifier
	Name            string
	HasSubFolders   bool
	MessageCount    int32
	PropertyContext *PropertyContext
	File            *File
}

Folder represents a folder.

func (*Folder) GetAllMessages

func (folder *Folder) GetAllMessages() ([]*Message, error)

GetAllMessages returns an array of all messages from the message table context. See GetMessageIterator.

func (*Folder) GetMessageIterator

func (folder *Folder) GetMessageIterator() (MessageIterator, error)

GetMessageIterator returns an iterator for messages.

func (*Folder) GetMessageTableContext

func (folder *Folder) GetMessageTableContext() (TableContext, error)

GetMessageTableContext returns the message table context of this folder which contains references to all messages. Note this only returns the identifier of each message.

func (*Folder) GetSubFolders

func (folder *Folder) GetSubFolders() ([]Folder, error)

GetSubFolders returns the sub-folders of this folder.

func (*Folder) GetSubFoldersTableContext

func (folder *Folder) GetSubFoldersTableContext() (TableContext, error)

GetSubFoldersTableContext returns the TableContext for the sub-folders of this folder. Note this limits the returned properties to the ones we use in the Folder struct.

func (*Folder) WalkFolders

func (folder *Folder) WalkFolders(walkFolderFunc WalkFolderFunc) error

WalkFolders recursively walks the sub-folders of this folder.

type FormatType

type FormatType uint8

FormatType represents a Unicode or ANSI format type.

const (
	FormatTypeANSI FormatType = iota
	FormatTypeUnicode
	FormatTypeUnicode4k
)

Constants defining the format types. References "Format Types".

type GUID

type GUID struct {
	Data1 uint32
	Data2 uint16
	Data3 uint16
	Data4 [8]byte
}

GUID represents a GUID/UUID. It has the same structure as golang.org/x/sys/windows.GUID so that it can be used with functions expecting that type. It is defined as its own type as that is only available to builds targeted at `windows`. The representation matches that used by native Windows code.

func GUIDFromWindowsArray

func GUIDFromWindowsArray(b []byte) GUID

GUIDFromWindowsArray constructs a GUID from a Windows encoding array of bytes. References https://github.com/microsoft/go-winio/blob/master/pkg/guid/guid.go

func (GUID) String

func (g GUID) String() string

type HeapOnNode

type HeapOnNode struct {
	Reader *HeapOnNodeReader
}

HeapOnNode represents a Heap-on-Node.

func (*HeapOnNode) GetHIDUserRoot

func (heapOnNode *HeapOnNode) GetHIDUserRoot() (Identifier, error)

GetHIDUserRoot returns the HID user root. References "Heap-on-Node header".

func (*HeapOnNode) GetTableType

func (heapOnNode *HeapOnNode) GetTableType() (uint8, error)

GetTableType returns the table type. References "Heap-on-Node header", "Table types".

func (*HeapOnNode) IsValidSignature

func (heapOnNode *HeapOnNode) IsValidSignature() (bool, error)

IsValidSignature returns true if the signature of the block matches 0xEC (236). References "Heap-on-Node header".

type HeapOnNodeReader

type HeapOnNodeReader struct {
	Blocks         []io.SectionReader
	BlockOffsets   []int64
	TotalBlockSize int64
	EncryptionType EncryptionType
}

HeapOnNodeReader implements io.SectionReader.

func NewHeapOnNodeReader

func NewHeapOnNodeReader(encryptionType EncryptionType, blocks ...io.SectionReader) *HeapOnNodeReader

NewHeapOnNodeReader creates a new Heap-on-Node reader.

func (*HeapOnNodeReader) DecodeCompressibleEncryption

func (heapOnNodeReader *HeapOnNodeReader) DecodeCompressibleEncryption(data []byte) []byte

DecodeCompressibleEncryption decodes the Heap-on-Node using compressible encryption. References "Compressible encryption".

func (*HeapOnNodeReader) ReadAt

func (heapOnNodeReader *HeapOnNodeReader) ReadAt(p []byte, off int64) (n int, err error)

ReadAt is adapted from Brad Fitz (http://talks.golang.org/2013/oscon-dl/sizereaderat.go).

func (*HeapOnNodeReader) Size

func (heapOnNodeReader *HeapOnNodeReader) Size() int64

Size is the total byte size.

type Identifier

type Identifier int64

Identifier represents a b-tree node identifier. TODO - Document the int types per use case and use separate types.

const (
	IdentifierRootFolder   Identifier = 290
	IdentifierMessageStore Identifier = 33
	IdentifierNameToIDMap  Identifier = 97
)

Constants defining the special b-tree node identifiers.

func GetBTreeNodeEntryDataIdentifier

func GetBTreeNodeEntryDataIdentifier(btreeNodeEntryData []byte, formatType FormatType) Identifier

GetBTreeNodeEntryDataIdentifier returns the node identifier of the data (in the block b-tree). References "The b-tree entries".

func GetBTreeNodeEntryIdentifier

func GetBTreeNodeEntryIdentifier(btreeNodeEntryData []byte, formatType FormatType) Identifier

GetBTreeNodeEntryIdentifier returns the Identifier of this b-tree node entry. References "The b-tree entries".

func GetBTreeNodeEntryLocalDescriptorsIdentifier

func GetBTreeNodeEntryLocalDescriptorsIdentifier(btreeNodeEntryData []byte, formatType FormatType) Identifier

GetBTreeNodeEntryLocalDescriptorsIdentifier returns the identifier to the local descriptors in the block b-tree.

func GetIdentifierFromBytes

func GetIdentifierFromBytes(identifierBytes []byte, formatType FormatType) Identifier

GetIdentifierFromBytes returns the Identifier type from bytes.

func (Identifier) GetType

func (identifier Identifier) GetType() IdentifierType

GetType returns the IdentifierType of this Identifier.

type IdentifierType

type IdentifierType uint8

IdentifierType represents the type of Identifier.

const (
	IdentifierTypeHID                     IdentifierType = 0
	IdentifierTypeInternal                IdentifierType = 1
	IdentifierTypeNormalFolder            IdentifierType = 2
	IdentifierTypeSearchFolder            IdentifierType = 3
	IdentifierTypeNormalMessage           IdentifierType = 4
	IdentifierTypeAttachment              IdentifierType = 5
	IdentifierTypeSearchUpdateQueue       IdentifierType = 6
	IdentifierTypeSearchCriteriaObject    IdentifierType = 7
	IdentifierTypeAssociatedMessage       IdentifierType = 8
	IdentifierTypeContentsTableIndex      IdentifierType = 10
	IdentifierTypeReceiveFolderTable      IdentifierType = 11
	IdentifierTypeOutgoingQueueTable      IdentifierType = 12
	IdentifierTypeHierarchyTable          IdentifierType = 13
	IdentifierTypeContentsTable           IdentifierType = 14
	IdentifierTypeAssociatedContentsTable IdentifierType = 15
	IdentifierTypeSearchContentsTable     IdentifierType = 16
	IdentifierTypeAttachmentTable         IdentifierType = 17
	IdentifierTypeRecipientTable          IdentifierType = 18
	IdentifierTypeSearchTableIndex        IdentifierType = 19
	IdentifierTypeLTP                     IdentifierType = 31
)

Constants defining the identifier types. References "Identifier types".

type LocalDescriptor

type LocalDescriptor struct {
	Identifier                 Identifier
	DataIdentifier             Identifier
	LocalDescriptorsIdentifier Identifier
}

LocalDescriptor represents an item in the local descriptors. A local descriptor is basically a reference to a node which contains the data.

func FindLocalDescriptor

func FindLocalDescriptor(identifier Identifier, localDescriptors []LocalDescriptor) (LocalDescriptor, error)

FindLocalDescriptor returns the local descriptor with the specified identifier or an error if not found.

func NewLocalDescriptor

func NewLocalDescriptor(data []byte, formatType FormatType) LocalDescriptor

NewLocalDescriptor creates a new local descriptor.

type Message

type Message struct {
	File                   *File
	Identifier             Identifier
	PropertyContext        *PropertyContext
	AttachmentTableContext *TableContext
	LocalDescriptors       []LocalDescriptor // Used by the PropertyContext and TableContext.
	Properties             msgp.Decodable    // Type properties.Message, properties.Appointment, properties.Contact
}

Message represents a message.

func (*Message) GetAllAttachments

func (message *Message) GetAllAttachments() ([]*Attachment, error)

GetAllAttachments returns the attachments of this message. See AttachmentIterator.

func (*Message) GetAttachment

func (message *Message) GetAttachment(attachmentIndex int) (*Attachment, error)

GetAttachment returns the specified attachment.

func (*Message) GetAttachmentCount

func (message *Message) GetAttachmentCount() (int, error)

GetAttachmentCount returns the amount of rows in the attachment table context.

func (*Message) GetAttachmentIterator

func (message *Message) GetAttachmentIterator() (AttachmentIterator, error)

GetAttachmentIterator returns an iterator for attachments.

func (*Message) GetAttachmentTableContext

func (message *Message) GetAttachmentTableContext() (*TableContext, error)

GetAttachmentTableContext returns the table context of the attachments of this message. Note we only return the attachment identifier property.

func (*Message) GetBodyRTF

func (message *Message) GetBodyRTF() (string, error)

GetBodyRTF return the RTF body, may be

func (*Message) HasAttachments

func (message *Message) HasAttachments() (bool, error)

HasAttachments returns true if this message has attachments.

type MessageIterator

type MessageIterator struct {
	// contains filtered or unexported fields
}

MessageIterator implements a message iterator.

func (*MessageIterator) CurrentIndex

func (messageIterator *MessageIterator) CurrentIndex() int

func (*MessageIterator) Err

func (messageIterator *MessageIterator) Err() error

Err return the error cause.

func (*MessageIterator) Next

func (messageIterator *MessageIterator) Next() bool

Next will ensure that Value returns the next item when executed. If the next value is not retrievable, Next will return false and Err() will return the error cause.

func (*MessageIterator) Size

func (messageIterator *MessageIterator) Size() int

Size returns the amount of messages in the message iterator.

func (*MessageIterator) Value

func (messageIterator *MessageIterator) Value() *Message

Value returns the current value in the iterator.

type NameToIDMap

type NameToIDMap struct {
	PropertySets []string
	NameToID     map[int]int
	IDToName     map[int]int
	StringToID   map[string]int
	IDToString   map[int]string
}

NameToIDMap represents the Name-To-ID Map.

func (*NameToIDMap) GetPropertyID

func (nameToIDMap *NameToIDMap) GetPropertyID(key int, propertySet PropertySet) (int, error)

GetPropertyID returns the Name-To-ID property ID.

type Property

type Property struct {
	ID   uint16
	Type PropertyType
	HNID Identifier
	// Data is only used for small values.
	// <= 8 bytes for the Table Context.
	// <= 4 bytes for the Property Context.
	// Other values will use the HNID.
	Data []byte
}

Property represents a property in the PropertyContext or TableContext. See PropertyReader.

type PropertyContext

type PropertyContext struct {
	Properties []Property
	HeapOnNode *HeapOnNode
	File       *File
}

PropertyContext represents the property context.

func (*PropertyContext) GetPropertyByID

func (propertyContext *PropertyContext) GetPropertyByID(propertyID uint16) (Property, error)

GetPropertyByID returns the property by ID.

func (*PropertyContext) GetPropertyReader

func (propertyContext *PropertyContext) GetPropertyReader(propertyID uint16, localDescriptors []LocalDescriptor) (PropertyReader, error)

GetPropertyReader returns the reader for the property, may return ErrPropertyNotFound.

func (*PropertyContext) Populate

func (propertyContext *PropertyContext) Populate(decodable msgp.Decodable, localDescriptors []LocalDescriptor) error

Populate all properties to the decodable.

type PropertyReader

type PropertyReader struct {
	Property         Property
	HeapOnNodeReader *HeapOnNodeReader
	LocalDescriptors []LocalDescriptor
	File             *File
}

PropertyReader allows reading a property from the Property/Table Context. References [MS-OXCDATA]: 2.11.1 Property Data Types. Implements io.SectionReader.

func NewPropertyReader

func NewPropertyReader(property Property, heapOnNode *HeapOnNode, file *File, localDescriptors []LocalDescriptor) (PropertyReader, error)

NewPropertyReader creates a new property reader.

func (*PropertyReader) DecodeString

func (propertyReader *PropertyReader) DecodeString(data []byte) (string, error)

DecodeString decodes the PropertyTypeString using Unicode (UTF-16LE). References [MS-OXCDATA]: 2.11.1 Property Data Types.

func (*PropertyReader) DecodeString8

func (propertyReader *PropertyReader) DecodeString8(data []byte, codePageIdentifier int) (string, error)

DecodeString8 decodes the PropertyTypeString8 using the code page identifier.

func (*PropertyReader) GetBoolean

func (propertyReader *PropertyReader) GetBoolean() (bool, error)

GetBoolean returns the boolean value of this property.

func (*PropertyReader) GetDate

func (propertyReader *PropertyReader) GetDate() (int64, error)

GetDate returns the date value (Unix Nano epoch) of the property context item.

func (*PropertyReader) GetInteger16

func (propertyReader *PropertyReader) GetInteger16() (int16, error)

GetInteger16 returns the 16-bit integer value of the property.

func (*PropertyReader) GetInteger32

func (propertyReader *PropertyReader) GetInteger32() (int32, error)

GetInteger32 returns the 32-bit integer value of the property.

func (*PropertyReader) GetInteger64

func (propertyReader *PropertyReader) GetInteger64() (int64, error)

GetInteger64 returns the 64-bit integer value of the property.

func (*PropertyReader) GetString

func (propertyReader *PropertyReader) GetString() (string, error)

GetString returns the string value of the property.

func (*PropertyReader) GetString8

func (propertyReader *PropertyReader) GetString8(codepageIdentifier int) (string, error)

GetString8 returns the string using the external encoding.

func (*PropertyReader) ReadAt

func (propertyReader *PropertyReader) ReadAt(outputBuffer []byte, offset int64) (int, error)

ReadAt reads the underlying Heap-on-Node.

func (*PropertyReader) Size

func (propertyReader *PropertyReader) Size() int64

Size returns the size of the Heap-on-Node.

func (*PropertyReader) WriteMessagePackValue

func (propertyReader *PropertyReader) WriteMessagePackValue(writer *msgp.Writer) error

WriteMessagePackValue writes the Message Pack format of the property value. Used to populate struct fields.

type PropertySet

type PropertySet uint8

PropertySet represents a collection of properties.

const (
	PropertySetPublicStrings PropertySet = iota
	PropertySetCommon
	PropertySetAddress
	PropertySetInternetHeaders
	PropertySetAppointment
	PropertySetMeeting
	PropertySetLog
	PropertySetMessaging
	PropertySetNote
	PropertySetPostRSS
	PropertySetTask
	PropertySetUnifiedMessaging
	PropertySetMAPI
	PropertySetAirSync
	PropertySetSharing
	PropertySetXMLExtractedEntities
	PropertySetAttachment
)

Constants defining the commonly used property sets. Note that the defined order is important and reflects the PropertySets array.

type PropertyType

type PropertyType uint16

PropertyType represents the data type of the property.

const (
	PropertyTypeInteger16            PropertyType = 2
	PropertyTypeInteger32            PropertyType = 3
	PropertyTypeFloating32           PropertyType = 4
	PropertyTypeFloating64           PropertyType = 5
	PropertyTypeCurrency             PropertyType = 6
	PropertyTypeFloatingTime         PropertyType = 7
	PropertyTypeErrorCode            PropertyType = 10
	PropertyTypeBoolean              PropertyType = 11
	PropertyTypeInteger64            PropertyType = 20
	PropertyTypeString               PropertyType = 31
	PropertyTypeString8              PropertyType = 30
	PropertyTypeTime                 PropertyType = 64
	PropertyTypeGUID                 PropertyType = 72
	PropertyTypeServerID             PropertyType = 251
	PropertyTypeRestriction          PropertyType = 253
	PropertyTypeRuleAction           PropertyType = 254
	PropertyTypeBinary               PropertyType = 258
	PropertyTypeMultipleInteger16    PropertyType = 4098
	PropertyTypeMultipleInteger32    PropertyType = 4099
	PropertyTypeMultipleFloating32   PropertyType = 4100
	PropertyTypeMultipleFloating64   PropertyType = 4101
	PropertyTypeMultipleCurrency     PropertyType = 4102
	PropertyTypeMultipleFloatingTime PropertyType = 4103
	PropertyTypeMultipleInteger64    PropertyType = 4116
	PropertyTypeMultipleString       PropertyType = 4127
	PropertyTypeMultipleString8      PropertyType = 4126
	PropertyTypeMultipleTime         PropertyType = 4160
	PropertyTypeMultipleGUID         PropertyType = 4168
	PropertyTypeMultipleBinary       PropertyType = 4354
	PropertyTypeUnspecified          PropertyType = 0
	PropertyTypeNull                 PropertyType = 1
	PropertyTypeObject               PropertyType = 13
)

Constants defining the property types.

References "Property types". References [MS-OXCDATA]: 2.11.1 Property Data Types

func (PropertyType) GetDataSize

func (propertyType PropertyType) GetDataSize() int

GetDataSize returns the size of the data (in bytes) stored for this property type or -1 for variable sized data.

References [MS-OXCDATA]: 2.11.1 Property Data Types

type RTFDecoder

type RTFDecoder struct{}

func NewRTFDecoder

func NewRTFDecoder() *RTFDecoder

func (*RTFDecoder) Decode

func (rtfDecoder *RTFDecoder) Decode(data []byte) (string, error)

type Reader

type Reader interface {
	ReadAtAsync(outputBuffer []byte, offset uint64, callback func(err error)) (uint64, error)
	io.ReaderAt // Blocking call.
}

Reader defines the file reader used by go-pst to support asynchronous I/O. Non-linux systems will fall back to DefaultReader. See AsyncReader.

type TableContext

type TableContext struct {
	Properties [][]Property
	HeapOnNode *HeapOnNode
	File       *File
}

TableContext represents the table context.

func (*TableContext) GetPropertyReader

func (tableContext *TableContext) GetPropertyReader(property Property, localDescriptors ...LocalDescriptor) (PropertyReader, error)

GetPropertyReader returns reader of the property.

type WalkFolderFunc

type WalkFolderFunc = func(folder *Folder) error

WalkFolderFunc is the type of the function called by WalkFolders when visiting each folder.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL