-
Notifications
You must be signed in to change notification settings - Fork 7
/
perms.go
50 lines (40 loc) · 987 Bytes
/
perms.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
package ciqdb
import (
"encoding/binary"
//"strconv"
"strings"
)
type Permissions struct {
PRGSection
perms []Permission
}
func (p *Permissions) String() string {
var buf strings.Builder
buf.WriteString(p.PRGSection.String() + "\n")
for _, perm := range p.perms {
// so far, looks like you parse this as an int
// and then match it with the entry in $SDK/bin/api.db
// but there must be a SymbolTable way.. ?
buf.WriteString(" " + perm.String() + "\n")
}
return buf.String()
}
type Permission struct {
data []byte
}
func (p *Permission) String() string {
return apidb(int(binary.BigEndian.Uint32(p.data)))
}
func parsePermissions(p *PRG, t SecType, length int, data []byte) *Permissions {
perms := Permissions{
PRGSection: PRGSection{
Type: t,
length: length,
},
}
numPerms := int(binary.BigEndian.Uint16(data[0:2]))
for i := 0; i < numPerms; i++ {
perms.perms = append(perms.perms, Permission{data[i*4+2 : i*4+6]})
}
return &perms
}