forked from axigenmessaging/tnefdecoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattribute.go
67 lines (56 loc) · 1.38 KB
/
attribute.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package tnefdecoder
import (
"strings"
)
/**
* MAPI attributes & TNEF Attributes
*/
type Attribute struct {
Type string // mapi (decoded mapi property) or mapped (message or attachment mapped property)
// level: att
Level int
Id int
DataType int
Data []byte // generated only for mapped properties
Checksum []int //UINT16
GUID string
PropMapValueType int // 0 = int, 1 = string
PropMapValue GenericValue
}
func (a *Attribute) GetStringValue() string {
v := ""
switch a.DataType {
case MapiTypeString8:
v = MapiDecodeString8(a.Data)
case MapiTypeUnicode:
v = MapiDecodeUnicode(a.Data)
default:
v = string(a.Data)
}
return strings.TrimSuffix(v, "\x00")
}
func (a *Attribute) GetStringValueArray() []string {
result := []string{""}
switch a.DataType {
case MapiTypeMVString8:
result = MapiDecodeString8Array(a.Data)
case MapiTypeMVUnicode:
result = MapiDecodeUnicodeArray(a.Data)
}
return result
}
func (a *Attribute) GetIntValue() int {
return MapiDecodeInt(a.Data, a.DataType)
}
func (a *Attribute) GetBoolValue() bool {
return MapiDecodeBoolean(a.Data)
}
func (a *Attribute) GetObjectValue() []byte {
return MapiDecodeObject(a.Data)
}
func (a *Attribute) GetBinaryValue() []byte {
return MapiDecodeBinary(a.Data)
}
func (a *Attribute) GetBinaryValueArray() [][]byte {
return MapiDecodeBinaryArray(a.Data)
}